import { of } from './of' ; describe ( 'of()' , ( ) => { describe ( 'when promise resolves' , ( ) => { const promise = new Promise ( ( resolve ) => resolve ( ) ) . then ( ( ) => 123 ) ; test ( 'first member of 3-tuple is the promise value' , async ( ) => { const [ result ] = await of ( promise ) ; expect ( result ) . toBe ( 123 ) ; } ) ; test ( 'second member of 3-tuple is undefined' , async ( ) => { const [ , error ] = await of ( promise ) ; expect ( error ) . toBe ( undefined ) ; } ) ; test ( 'third, flag member, of 3-tuple is true' , async ( ) => { const [ , , resolved ] = await of ( promise ) ; expect ( resolved ) . toBe ( true ) ; } ) ; } ) ; describe ( 'when promise rejects' , ( ) => { const promise = new Promise ( ( resolve ) => resolve ( ) ) . then ( ( ) => { throw 123 ; } ) ; test ( 'first member of 3-tuple is undefined' , async ( ) => { const [ result ] = await of ( promise ) ; expect ( result ) . toBe ( undefined ) ; } ) ; test ( 'second member of 3-tuple is thrown error' , async ( ) => { const [ , error ] = await of ( promise ) ; expect ( error ) . toBe ( 123 ) ; } ) ; test ( 'third, flag member, of 3-tuple is false' , async ( ) => { const [ , , resolved ] = await of ( promise ) ; expect ( resolved ) . toBe ( false ) ; } ) ; } ) ; } ) ;