Skip to content

Commit 6757009

Browse files
authored
chore(async-rewriter): add test for fn as default arg of other fn (#2402)
1 parent d0132aa commit 6757009

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

packages/async-rewriter2/src/async-writer-babel.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,16 @@ describe('AsyncWriter', function () {
561561
expect(await ret).to.equal('bar');
562562
});
563563

564+
it('supports awaiting inside a function which is a default argument of another function', async function () {
565+
implicitlyAsyncFn.resolves({ nested: [{ foo: 'bar' }] });
566+
const ret = runTranspiledCode(`
567+
const call = (fn = foo => foo.nested[0].foo, ...args) => fn(...args);
568+
call(undefined, implicitlyAsyncFn())`);
569+
expect(ret.constructor.name).to.equal('Promise');
570+
expect(ret[Symbol.for('@@mongosh.syntheticPromise')]).to.equal(true);
571+
expect(await ret).to.equal('bar');
572+
});
573+
564574
context('for-of', function () {
565575
it('can iterate over implicit iterables', async function () {
566576
expect(

0 commit comments

Comments
 (0)