import { EventEmitter } from "events" ; import * as core from "@fluidframework/server-services-core" ; export interface IEvent { event : string ; args : any [ ] ; } export class TestTopic implements core . ITopic { public events = new Map < string , IEvent [ ] > ( ) ; public emit ( event , ... args ) { if ( ! this . events . has ( event ) ) { this . events . set ( event , [ ] ) ; } this . events . get ( event ) . push ( { args , event } ) ; } public getEvents ( key ) { return this . events . get ( key ) ; } } export class TestPublisher implements core . IPublisher { private readonly events = new EventEmitter ( ) ; private topics : { [ topic ] : TestTopic ; } = { } ; public on ( event , listener ) { this . events . on ( event , listener ) ; } public to ( topic ) { if ( ! ( topic in this . topics ) ) { this . topics [ topic ] = new TestTopic ( ) ; } return this . topics [ topic ] ; } public async close ( ) { } }