-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathmqemitter.test-d.ts
More file actions
33 lines (23 loc) · 861 Bytes
/
mqemitter.test-d.ts
File metadata and controls
33 lines (23 loc) · 861 Bytes
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
import { expectError, expectType } from 'tsd'
import mqEmitter from '../mqemitter'
import type { Message, MQEmitter } from '../mqemitter'
expectType<MQEmitter>(mqEmitter())
expectType<MQEmitter>(mqEmitter({ concurrency: 200, matchEmptyLevels: true }))
expectType<MQEmitter>(
mqEmitter({
concurrency: 10,
matchEmptyLevels: true,
separator: '/',
wildcardOne: '+',
wildcardSome: '#',
})
)
function listener (message: Message, done: () => void) {}
expectType<MQEmitter>(mqEmitter().on('topic', listener))
expectError(mqEmitter().emit(null))
expectType<void>(
mqEmitter().emit({ topic: 'test', prop1: 'prop1', [Symbol.for('me')]: 42 })
)
expectType<void>(mqEmitter().emit({ topic: 'test', prop1: 'prop1' }, () => {}))
expectType<void>(mqEmitter().removeListener('topic', listener))
expectType<void>(mqEmitter().close(() => null))