import 'mocha' ; import { expect } from 'chai' ; import { EventSubscriptionCollection } from '@/infrastructure/Events/EventSubscriptionCollection' ; import { IEventSubscription } from '@/infrastructure/Events/IEventSource' ; describe ( 'EventSubscriptionCollection' , ( ) => { it ( 'unsubscribeAll unsubscribes from all registered subscriptions' , ( ) => { const sut = new EventSubscriptionCollection ( ) ; const expected = [ 'unsubscribed1' , 'unsubscribed2' ] ; const actual = new Array < string > ( ) ; const subscriptions = [ { unsubscribe : ( ) => actual . push ( expected [ 0 ] ) } , { unsubscribe : ( ) => actual . push ( expected [ 1 ] ) } , ] ; sut . register ( ... subscriptions ) ; sut . unsubscribeAll ( ) ; expect ( actual ) . to . deep . equal ( expected ) ; } ) ; } ) ;