import { P2P , events } from '../../../src/index' ; import { wait } from '../../utils/helpers' ; import { createNetwork , destroyNetwork } from '../../utils/network_setup' ; const { EVENT_NETWORK_READY } = events ; describe ( `Event on ${ EVENT_NETWORK_READY }` , ( ) => { let p2pNodeList = [ ] ; const collectedEvents = new Map ( ) ; beforeEach ( async ( ) => { p2pNodeList = await createNetwork ( { networkSize : 2 , networkDiscoveryWaitTime : 1 , } ) ; const secondNode = p2pNodeList [ 1 ] ; secondNode . on ( EVENT_NETWORK_READY , ( ) => { collectedEvents . set ( EVENT_NETWORK_READY , true ) ; } ) ; await wait ( 1000 ) ; } ) ; afterEach ( async ( ) => { await destroyNetwork ( p2pNodeList ) ; } ) ; it ( `should fire ${ EVENT_NETWORK_READY } event` , ( ) => { expect ( collectedEvents . get ( EVENT_NETWORK_READY ) ) . toBeDefined ( ) ; } ) ; } ) ;