-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.test.js
47 lines (44 loc) · 1.4 KB
/
index.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
35
36
37
38
39
40
41
42
43
44
45
46
47
import { assert, test } from 'vitest'
import Parser from './index.ts'
test('should emit "message" events', () =>
new Promise((done) => {
const parser = new Parser()
let n = 0
parser.on('message', (msg) => {
switch (n++) {
case 0:
assert.equal('hitchcock.freenode.net', msg.prefix)
assert.equal('NOTICE', msg.command)
assert.equal('*', msg.params)
assert.equal('*** Looking up your hostname...', msg.trailing)
assert(msg.string)
break
case 1:
assert.equal('', msg.prefix)
assert.equal('ERROR', msg.command)
assert.equal('', msg.params)
assert.equal(
'Closing Link: 127.0.0.1 (Connection timed out)',
msg.trailing,
)
break
case 2:
assert.equal(
msg.prefix,
)
assert.equal('JOIN', msg.command)
assert.equal('#express', msg.params)
assert.equal('', msg.trailing)
done()
break
}
})
parser.write(
':hitchcock.freenode.net NOTICE * :*** Looking up your hostname...\r\n',
)
parser.write('ERROR :Closing Link: 127.0.0.1 (Connection timed out)\r\n')
parser.write(
':[email protected] JOIN #express\r\n',
)
}))