event emitter test

This commit is contained in:
Charles Driesler
2024-06-28 12:41:49 +01:00
parent b0344b1eae
commit fc69e26905
4 changed files with 57 additions and 18 deletions
@@ -57,6 +57,39 @@ describe('Workspace creation', () => {
role: Roles.Workspace.Admin
})
})
it('emits a workspace created event', async () => {})
it('emits a workspace created event', async () => {
const eventData = {
isCalled: false,
event: '',
payload: {}
}
const createWorkspace = createWorkspaceFactory({
storeWorkspace: async () => {},
upsertWorkspaceRole: async () => {},
emitWorkspaceEvent: async ({ event, payload }) => {
eventData.isCalled = true
eventData.event = event
eventData.payload = payload
return []
},
storeBlob: async () => cryptoRandomString({ length: 10 })
})
const workspaceInput = {
description: 'foobar',
logo: null,
name: cryptoRandomString({ length: 6 })
}
const userId = cryptoRandomString({ length: 10 })
const workspace = await createWorkspace({
userId,
workspaceInput
})
expect(eventData.isCalled).to.equal(true)
expect(eventData.payload).to.equal('created')
expect(eventData.payload).to.deep.equal(workspace)
})
})
})