diff --git a/test/fixtures/21-incorrect-return/.babelrc b/test/fixtures/21-incorrect-return/.babelrc new file mode 100644 index 0000000..e624888 --- /dev/null +++ b/test/fixtures/21-incorrect-return/.babelrc @@ -0,0 +1,5 @@ +{ + "plugins": [ + ["../../../src"] + ] +} diff --git a/test/fixtures/21-incorrect-return/actual.js b/test/fixtures/21-incorrect-return/actual.js new file mode 100644 index 0000000..1ab2fe8 --- /dev/null +++ b/test/fixtures/21-incorrect-return/actual.js @@ -0,0 +1,10 @@ +async function handler() { + var response = await fetch('http://address'); + if (!response.ok) { + return null; // 1 + } + var json = await response.json(); // 2 + return { + a: 3 + }; +} diff --git a/test/fixtures/21-incorrect-return/expected.js b/test/fixtures/21-incorrect-return/expected.js new file mode 100644 index 0000000..2a85daa --- /dev/null +++ b/test/fixtures/21-incorrect-return/expected.js @@ -0,0 +1,22 @@ +function handler() { + var response, json; + return Promise.resolve().then(function () { + return fetch('http://address'); + }).then(function (_resp) { + response = _resp; + + if (!response.ok) { + return null; // 1 + } else { + return Promise.resolve().then(function () { + return response.json(); + }).then(function (_resp) { + json = _resp; // 2 + + return { + a: 3 + }; + }); + } + }); +}