-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tenants): initial tenants module (#932)
Signed-off-by: Timo Glastra <[email protected]>
- Loading branch information
1 parent
96c5ef8
commit ec2f014
Showing
67 changed files
with
2,012 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import type { EventEmitter as NativeEventEmitter } from 'events' | ||
|
||
import { Subject } from 'rxjs' | ||
|
||
import { agentDependencies, getAgentContext } from '../../../tests/helpers' | ||
import { EventEmitter } from '../EventEmitter' | ||
|
||
const mockEmit = jest.fn() | ||
const mockOn = jest.fn() | ||
const mockOff = jest.fn() | ||
const mock = jest.fn().mockImplementation(() => { | ||
return { emit: mockEmit, on: mockOn, off: mockOff } | ||
}) as jest.Mock<NativeEventEmitter> | ||
|
||
const eventEmitter = new EventEmitter( | ||
{ ...agentDependencies, EventEmitterClass: mock as unknown as typeof NativeEventEmitter }, | ||
new Subject() | ||
) | ||
const agentContext = getAgentContext({}) | ||
|
||
describe('EventEmitter', () => { | ||
afterEach(() => { | ||
jest.clearAllMocks() | ||
}) | ||
|
||
describe('emit', () => { | ||
test("calls 'emit' on native event emitter instance", () => { | ||
eventEmitter.emit(agentContext, { | ||
payload: { some: 'payload' }, | ||
type: 'some-event', | ||
}) | ||
|
||
expect(mockEmit).toHaveBeenCalledWith('some-event', { | ||
payload: { some: 'payload' }, | ||
type: 'some-event', | ||
metadata: { | ||
contextCorrelationId: agentContext.contextCorrelationId, | ||
}, | ||
}) | ||
}) | ||
}) | ||
|
||
describe('on', () => { | ||
test("calls 'on' on native event emitter instance", () => { | ||
const listener = jest.fn() | ||
eventEmitter.on('some-event', listener) | ||
|
||
expect(mockOn).toHaveBeenCalledWith('some-event', listener) | ||
}) | ||
}) | ||
describe('off', () => { | ||
test("calls 'off' on native event emitter instance", () => { | ||
const listener = jest.fn() | ||
eventEmitter.off('some-event', listener) | ||
|
||
expect(mockOff).toHaveBeenCalledWith('some-event', listener) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.