Skip to content

Commit

Permalink
updated tests with new evetn names
Browse files Browse the repository at this point in the history
Signed-off-by: NeilSMyers <[email protected]>
  • Loading branch information
NeilSMyers committed Nov 1, 2021
1 parent a0c7fea commit 52665b0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AgentConfig } from '../../../agent/AgentConfig'
import type { StorageService } from '../../../storage/StorageService'
import type { BasicMessageReceivedEvent } from '../BasicMessageEvents'
import type { BasicMessageStateChangedEvent } from '../BasicMessageEvents'

import { getAgentConfig, getMockConnection } from '../../../../tests/helpers'
import { EventEmitter } from '../../../agent/EventEmitter'
Expand Down Expand Up @@ -50,7 +50,7 @@ describe('BasicMessageService', () => {

it(`emits newMessage with message and basic message record`, async () => {
const eventListenerMock = jest.fn()
eventEmitter.on<BasicMessageReceivedEvent>(BasicMessageEventTypes.BasicMessageReceived, eventListenerMock)
eventEmitter.on<BasicMessageStateChangedEvent>(BasicMessageEventTypes.BasicMessageStateChanged, eventListenerMock)

const basicMessage = new BasicMessage({
id: '123',
Expand All @@ -65,7 +65,7 @@ describe('BasicMessageService', () => {
await basicMessageService.save(messageContext, mockConnectionRecord)

expect(eventListenerMock).toHaveBeenCalledWith({
type: 'BasicMessageReceived',
type: 'BasicMessageStateChanged',
payload: {
basicMessageRecord: expect.objectContaining({
connectionId: mockConnectionRecord.id,
Expand Down
8 changes: 4 additions & 4 deletions packages/core/tests/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { SubjectMessage } from '../../../tests/transport/SubjectInboundTran
import type {
AutoAcceptProof,
BasicMessage,
BasicMessageReceivedEvent,
BasicMessageStateChangedEvent,
ConnectionRecordProps,
CredentialDefinitionTemplate,
CredentialOfferTemplate,
Expand Down Expand Up @@ -184,17 +184,17 @@ export async function waitForCredentialRecord(

export async function waitForBasicMessage(agent: Agent, { content }: { content?: string }): Promise<BasicMessage> {
return new Promise((resolve) => {
const listener = (event: BasicMessageReceivedEvent) => {
const listener = (event: BasicMessageStateChangedEvent) => {
const contentMatches = content === undefined || event.payload.message.content === content

if (contentMatches) {
agent.events.off<BasicMessageReceivedEvent>(BasicMessageEventTypes.BasicMessageReceived, listener)
agent.events.off<BasicMessageStateChangedEvent>(BasicMessageEventTypes.BasicMessageStateChanged, listener)

resolve(event.payload.message)
}
}

agent.events.on<BasicMessageReceivedEvent>(BasicMessageEventTypes.BasicMessageReceived, listener)
agent.events.on<BasicMessageStateChangedEvent>(BasicMessageEventTypes.BasicMessageStateChanged, listener)
})
}

Expand Down

0 comments on commit 52665b0

Please sign in to comment.