import { TypedEventEmitter } from "@fluidframework/common-utils" ; import { ICommittedProposal , IQuorum , IQuorumEvents , ISequencedClient } from "@fluidframework/protocol-definitions" ; export class TestQuorum extends TypedEventEmitter < IQuorumEvents > implements IQuorum { public disposed = false ; public dispose ( ) { this . disposed = true ; } private readonly members = new Map < string , ISequencedClient > ( ) ; public getMembers ( ) { return this . members ; } public getMember ( clientId ) { return this . members . get ( clientId ) ; } private readonly values = new Map < string , any > ( ) ; public async propose ( key , value ) { this . values . set ( key , value ) ; } public has ( key ) { return this . values . has ( key ) ; } public get ( key ) { return this . values . get ( key ) ; } public getApprovalData ( key ) { const value = this . values . get ( key ) ; if ( value === undefined ) { return undefined ; } return { key , value , commitSequenceNumber : 0 , approvalSequenceNumber : 0 , sequenceNumber : 0 } ; } public addClient ( clientId , client ) { this . members . set ( clientId , client ) ; this . emit ( "addMember" , clientId , client ) ; } public removeClient ( clientId ) { this . members . delete ( clientId ) ; this . emit ( "removeMember" , clientId ) ; } public reset ( ) { this . members . clear ( ) ; this . values . clear ( ) ; this . removeAllListeners ( ) ; } }