import { EntityCacheAdapterTransientError } from '@expo/entity' ; import wrapNativeRedisCallAsync from '../wrapNativeRedisCallAsync' ; describe ( wrapNativeRedisCallAsync , ( ) => { it ( 'rethrows literals' , async ( ) => { const throwingFn = async ( ) : Promise < void > => { throw 'hello' ; } ; let capturedThrownThing ; try { await wrapNativeRedisCallAsync ( throwingFn ) ; } catch ( e ) { capturedThrownThing = e ; } expect ( capturedThrownThing ) . not . toBeInstanceOf ( Error ) ; expect ( capturedThrownThing ) . toEqual ( 'hello' ) ; } ) ; it ( 'wraps errors with stacks' , async ( ) => { const throwingFn = async ( ) : Promise < void > => { const e = new Error ( 'hello' ) ; e . stack = 'world' ; throw e ; } ; let capturedThrownThing ; try { await wrapNativeRedisCallAsync ( throwingFn ) ; } catch ( e ) { capturedThrownThing = e ; } expect ( capturedThrownThing ) . toBeInstanceOf ( EntityCacheAdapterTransientError ) ; expect ( capturedThrownThing . message ) . toEqual ( 'hello' ) ; expect ( capturedThrownThing . stack ) . toEqual ( 'world' ) ; } ) ; } ) ;