import { describe , it } from '@effection/mocha' ; import expect from 'expect' ; import { Subscription , Task , sleep , spawn } from 'effection' ; import { inspect , InspectMessage } from '../src/index' ; function expectContainsObject < R > ( actual , matching ) { expect ( actual ) . toEqual ( expect . arrayContaining ( [ expect . objectContaining ( matching ) ] ) ) ; } describe ( "inspect()" , ( ) => { it ( 'returns a slice of the task tree' , function * ( ) { let task = yield spawn ( ) ; let buffer = yield inspect ( task ) . toBuffer ( ) ; let child = yield task . spawn ( function * ( ) { yield spawn ( ) ; yield spawn ( function * ( ) { } ) ; yield sleep ( ) ; } , { labels : { name : 'root' } } ) ; expectContainsObject ( buffer , { type : 'link' , id : task . id , child : expect . objectContaining ( { id : child . id } ) } ) ; } ) ; } ) ;