File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
packages/async-rewriter2/src Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -370,6 +370,16 @@ describe('AsyncWriter', function () {
370370 expect ( await ret ) . to . equal ( 'bar' ) ;
371371 } ) ;
372372
373+ it ( 'can implicitly await inside of template literals' , async function ( ) {
374+ implicitlyAsyncFn . resolves ( 'foobar' ) ;
375+ const ret = runTranspiledCode (
376+ '(() => { return `>>${implicitlyAsyncFn()}<<`; })()'
377+ ) ;
378+ expect ( ret . constructor . name ) . to . equal ( 'Promise' ) ;
379+ expect ( ret [ Symbol . for ( '@@mongosh.syntheticPromise' ) ] ) . to . equal ( true ) ;
380+ expect ( await ret ) . to . equal ( '>>foobar<<' ) ;
381+ } ) ;
382+
373383 it ( 'can implicitly await inside of branches' , async function ( ) {
374384 implicitlyAsyncFn . resolves ( { foo : 'bar' } ) ;
375385 const ret = runTranspiledCode ( `
@@ -476,6 +486,10 @@ describe('AsyncWriter', function () {
476486 expect ( runTranspiledCode ( 'typeof nonexistent' ) ) . to . equal ( 'undefined' ) ;
477487 } ) ;
478488
489+ it ( 'supports typeof for un-defined variables in parentheses' , function ( ) {
490+ expect ( runTranspiledCode ( 'typeof ((nonexistent))' ) ) . to . equal ( 'undefined' ) ;
491+ } ) ;
492+
479493 it ( 'supports typeof for implicitly awaited function calls' , async function ( ) {
480494 implicitlyAsyncFn . resolves ( 0 ) ;
481495 expect ( await runTranspiledCode ( 'typeof implicitlyAsyncFn()' ) ) . to . equal (
You can’t perform that action at this time.
0 commit comments