From: Evan You Date: Fri, 10 Jul 2020 22:00:13 +0000 (-0400) Subject: feat(compiler-sfc): ``) + expect(content).toMatch( + `export ${shouldAsync ? `async ` : ``}function setup` + ) + } + + test('expression statement', () => { + assertAwaitDetection(`await foo`) + }) + + test('variable', () => { + assertAwaitDetection(`const a = 1 + (await foo)`) + }) + + test('export', () => { + assertAwaitDetection(`export const a = 1 + (await foo)`) + }) + + test('nested statements', () => { + assertAwaitDetection(`if (ok) { await foo } else { await bar }`) + }) + + test('should ignore await inside functions', () => { + // function declaration + assertAwaitDetection(`export async function foo() { await bar }`, false) + // function expression + assertAwaitDetection(`const foo = async () => { await bar }`, false) + // object method + assertAwaitDetection(`const obj = { async method() { await bar }}`, false) + // class method + assertAwaitDetection( + `const cls = class Foo { async method() { await bar }}`, + false + ) + }) + }) + describe('errors', () => { test('