forked from svt/bridge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevents.unit.test.js
34 lines (28 loc) · 885 Bytes
/
events.unit.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// SPDX-FileCopyrightText: 2023 Sveriges Television AB
//
// SPDX-License-Identifier: MIT
require('./events')
const DIController = require('../shared/DIController')
let events
beforeAll(() => {
events = DIController.main.instantiate('Events', {
Commands: {
registerCommand: () => {},
executeCommand: () => {}
}
})
})
test('create a new caller scope', () => {
const scope = events.createScope('mycaller')
expect(scope.id).toEqual('mycaller')
})
test('remove all listeners for a caller', () => {
const scope = events.createScope('mySecondcaller')
scope.on('test', () => {})
expect(events.removeAllListeners('mySecondcaller')).toEqual(1)
})
test('remove all intercepts for a caller', () => {
const scope = events.createScope('myThirdcaller')
scope.intercept('test', () => {})
expect(events.removeAllIntercepts('myThirdcaller')).toEqual(1)
})