Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/async-rewriter2/src/async-writer-babel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,16 @@ describe('AsyncWriter', function () {
expect(await ret).to.equal('bar');
});

it('can implicitly await inside of template literals', async function () {
implicitlyAsyncFn.resolves('foobar');
const ret = runTranspiledCode(
'(() => { return `>>${implicitlyAsyncFn()}<<`; })()'
);
expect(ret.constructor.name).to.equal('Promise');
expect(ret[Symbol.for('@@mongosh.syntheticPromise')]).to.equal(true);
expect(await ret).to.equal('>>foobar<<');
});

it('can implicitly await inside of branches', async function () {
implicitlyAsyncFn.resolves({ foo: 'bar' });
const ret = runTranspiledCode(`
Expand Down Expand Up @@ -476,6 +486,10 @@ describe('AsyncWriter', function () {
expect(runTranspiledCode('typeof nonexistent')).to.equal('undefined');
});

it('supports typeof for un-defined variables in parentheses', function () {
expect(runTranspiledCode('typeof ((nonexistent))')).to.equal('undefined');
});

it('supports typeof for implicitly awaited function calls', async function () {
implicitlyAsyncFn.resolves(0);
expect(await runTranspiledCode('typeof implicitlyAsyncFn()')).to.equal(
Expand Down
Loading