import { deprecated } from "../../src/utils" ; import { flow , createFlowSpawner } from "../../src/core/flow" ; import { process as mstProcess , createProcessSpawner } from "../../src/core/process" ; function createDeprecationListener ( ) { deprecated . ids = { } ; const originalWarn = console . warn ; const spyWarn = ( console . warn = jest . fn ( ) ) ; return function isDeprecated ( ) { console . warn = originalWarn ; if ( process . env . NODE_ENV !== "production" ) { expect ( spyWarn ) . toHaveBeenCalledTimes ( 1 ) ; expect ( spyWarn . mock . calls [ 0 ] [ 0 ] . message ) . toMatch ( /Deprecation warning:/ ) ; } } ; } test ( "`process` should mirror `flow`" , ( ) => { const isDeprecated = createDeprecationListener ( ) ; const generator = function * ( ) { } ; const flowResult = flow ( generator ) ; const processResult = mstProcess ( generator ) ; expect ( processResult . name ) . toBe ( flowResult . name ) ; isDeprecated ( ) ; } ) ; test ( "`createProcessSpawner` should mirror `createFlowSpawner`" , ( ) => { const isDeprecated = createDeprecationListener ( ) ; const alias = "generatorAlias" ; const generator = function * ( ) : IterableIterator < void > { } ; const flowSpawnerResult = createFlowSpawner ( alias , generator ) ; const processSpawnerResult = createProcessSpawner ( alias , generator ) ; expect ( processSpawnerResult . name ) . toBe ( flowSpawnerResult . name ) ; isDeprecated ( ) ; } ) ;