From 4c43d4e5b9df8732b601a269bf4030f9721d466f Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 10 Jul 2020 18:00:13 -0400 Subject: [PATCH] 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('