Skip to content

Commit e36bc24

Browse files
committed
test: Avoid the use of describe
1 parent 18e1c73 commit e36bc24

14 files changed

+423
-453
lines changed

test/away.test.js

+12-14
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
import { describe, it } from 'vitest'
1+
import { it } from 'vitest'
22
import 'should'
33

44
import irc from '..'
55
import { PassThrough as Stream } from 'stream'
66

7-
describe('on RPL_AWAY', () => {
8-
it('should emit "away"', () =>
9-
new Promise((done) => {
10-
var stream = new Stream()
11-
var client = irc(stream)
7+
it('should emit "away"', () =>
8+
new Promise((done) => {
9+
var stream = new Stream()
10+
var client = irc(stream)
1211

13-
client.on('away', function (e) {
14-
e.nick.should.equal('colinm')
15-
e.message.should.eql('brb food time')
16-
done()
17-
})
12+
client.on('away', function (e) {
13+
e.nick.should.equal('colinm')
14+
e.message.should.eql('brb food time')
15+
done()
16+
})
1817

19-
stream.write(':irc.host.net 301 me colinm :brb food time\r\n')
20-
}))
21-
})
18+
stream.write(':irc.host.net 301 me colinm :brb food time\r\n')
19+
}))

test/invite.test.js

+17-19
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
1-
import { describe, it } from 'vitest'
1+
import { it } from 'vitest'
22
import 'should'
33

44
import irc from '..'
55
import { PassThrough as Stream } from 'stream'
66

7-
describe('on INVITE', () => {
8-
it('should emit "invite"', () =>
9-
new Promise((done) => {
10-
var stream = new Stream()
11-
var client = irc(stream)
7+
it('should emit "invite"', () =>
8+
new Promise((done) => {
9+
var stream = new Stream()
10+
var client = irc(stream)
1211

13-
client.on('invite', function (e) {
14-
e.from.should.equal('test')
15-
e.to.should.equal('astranger')
16-
e.channel.should.equal('#something')
17-
e.hostmask.nick.should.equal('test')
18-
e.hostmask.username.should.equal('~user')
19-
e.hostmask.hostname.should.equal('example.com')
20-
e.hostmask.string.should.equal('test!~user@example.com')
21-
done()
22-
})
12+
client.on('invite', function (e) {
13+
e.from.should.equal('test')
14+
e.to.should.equal('astranger')
15+
e.channel.should.equal('#something')
16+
e.hostmask.nick.should.equal('test')
17+
e.hostmask.username.should.equal('~user')
18+
e.hostmask.hostname.should.equal('example.com')
19+
e.hostmask.string.should.equal('test!~user@example.com')
20+
done()
21+
})
2322

24-
stream.write(':test!~user@example.com INVITE astranger :#something\r\n')
25-
}))
26-
})
23+
stream.write(':test!~user@example.com INVITE astranger :#something\r\n')
24+
}))

test/join.test.js

+20-22
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
1-
import { describe, it } from 'vitest'
1+
import { it } from 'vitest'
22
import 'should'
33

44
import irc from '..'
55
import { PassThrough as Stream } from 'stream'
66

7-
describe('on JOIN', () => {
8-
it('should emit "join"', () =>
9-
new Promise((done) => {
10-
var stream = new Stream()
11-
var client = irc(stream)
7+
it('should emit "join"', () =>
8+
new Promise((done) => {
9+
var stream = new Stream()
10+
var client = irc(stream)
1211

13-
client.on('join', function (e) {
14-
e.nick.should.equal('tjholowaychuk')
15-
e.channel.should.equal('#express')
16-
e.hostmask.nick.should.equal('tjholowaychuk')
17-
e.hostmask.username.should.equal('~tjholoway')
18-
e.hostmask.hostname.should.equal('S01067cb21b2fd643.gv.shawcable.net')
19-
e.hostmask.string.should.equal(
20-
'tjholowaychuk!~tjholoway@S01067cb21b2fd643.gv.shawcable.net',
21-
)
22-
done()
23-
})
24-
25-
stream.write(
26-
':tjholowaychuk!~tjholoway@S01067cb21b2fd643.gv.shawcable.net JOIN #express\r\n',
12+
client.on('join', function (e) {
13+
e.nick.should.equal('tjholowaychuk')
14+
e.channel.should.equal('#express')
15+
e.hostmask.nick.should.equal('tjholowaychuk')
16+
e.hostmask.username.should.equal('~tjholoway')
17+
e.hostmask.hostname.should.equal('S01067cb21b2fd643.gv.shawcable.net')
18+
e.hostmask.string.should.equal(
19+
'tjholowaychuk!~tjholoway@S01067cb21b2fd643.gv.shawcable.net',
2720
)
28-
}))
29-
})
21+
done()
22+
})
23+
24+
stream.write(
25+
':tjholowaychuk!~tjholoway@S01067cb21b2fd643.gv.shawcable.net JOIN #express\r\n',
26+
)
27+
}))

test/kick.test.js

+21-23
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
1-
import { describe, it } from 'vitest'
1+
import { it } from 'vitest'
22
import 'should'
33

44
import irc from '..'
55
import { PassThrough as Stream } from 'stream'
66

7-
describe('on KICK', () => {
8-
it('should emit "kick"', () =>
9-
new Promise((done) => {
10-
var stream = new Stream()
11-
var client = irc(stream)
7+
it('should emit "kick"', () =>
8+
new Promise((done) => {
9+
var stream = new Stream()
10+
var client = irc(stream)
1211

13-
client.on('kick', function (e) {
14-
e.nick.should.equal('tjholowaychuk')
15-
e.client.should.equal('tobi')
16-
e.channel.should.eql('#express')
17-
e.hostmask.nick.should.equal('tjholowaychuk')
18-
e.hostmask.username.should.equal('~tjholoway')
19-
e.hostmask.hostname.should.equal('S01067cb21b2fd643.gv.shawcable.net')
20-
e.hostmask.string.should.equal(
21-
'tjholowaychuk!~tjholoway@S01067cb21b2fd643.gv.shawcable.net',
22-
)
23-
done()
24-
})
25-
26-
stream.write(
27-
':tjholowaychuk!~tjholoway@S01067cb21b2fd643.gv.shawcable.net KICK #express tobi :Too ferrety\r\n',
12+
client.on('kick', function (e) {
13+
e.nick.should.equal('tjholowaychuk')
14+
e.client.should.equal('tobi')
15+
e.channel.should.eql('#express')
16+
e.hostmask.nick.should.equal('tjholowaychuk')
17+
e.hostmask.username.should.equal('~tjholoway')
18+
e.hostmask.hostname.should.equal('S01067cb21b2fd643.gv.shawcable.net')
19+
e.hostmask.string.should.equal(
20+
'tjholowaychuk!~tjholoway@S01067cb21b2fd643.gv.shawcable.net',
2821
)
29-
}))
30-
})
22+
done()
23+
})
24+
25+
stream.write(
26+
':tjholowaychuk!~tjholoway@S01067cb21b2fd643.gv.shawcable.net KICK #express tobi :Too ferrety\r\n',
27+
)
28+
}))

test/names.test.js

+30-32
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,40 @@
1-
import { describe, it } from 'vitest'
1+
import { it } from 'vitest'
22
import 'should'
33

44
import irc from '..'
55
import { PassThrough as Stream } from 'stream'
66

7-
describe('client.names(chan, fn)', () => {
8-
it('should respond with user names', () =>
9-
new Promise((done) => {
10-
var stream = new Stream()
11-
var client = irc(stream)
7+
it('should respond with user names', () =>
8+
new Promise((done) => {
9+
var stream = new Stream()
10+
var client = irc(stream)
1211

13-
client.names('#luna-lang', function (err, names) {
14-
if (err) return done(err)
15-
names.should.eql([
16-
{ name: 'owner', mode: '~' },
17-
{ name: 'foo', mode: '@' },
18-
{ name: 'halfop', mode: '%' },
19-
{ name: 'bar', mode: '+' },
20-
{ name: 'baz', mode: '' },
21-
{ name: 'some', mode: '' },
22-
{ name: 'more', mode: '' },
23-
])
24-
done()
25-
})
12+
client.names('#luna-lang', function (err, names) {
13+
if (err) return done(err)
14+
names.should.eql([
15+
{ name: 'owner', mode: '~' },
16+
{ name: 'foo', mode: '@' },
17+
{ name: 'halfop', mode: '%' },
18+
{ name: 'bar', mode: '+' },
19+
{ name: 'baz', mode: '' },
20+
{ name: 'some', mode: '' },
21+
{ name: 'more', mode: '' },
22+
])
23+
done()
24+
})
2625

27-
setImmediate(() => {
28-
stream.write(
29-
':pratchett.freenode.net 353 tjholowaychuk = #luna-lang :~owner @foo %halfop +bar baz\r\n',
30-
)
31-
stream.write(
32-
':pratchett.freenode.net 353 tjholowaychuk = #luna-lang :some more\r\n',
33-
)
34-
stream.write(
35-
':pratchett.freenode.net 366 tjholowaychuk #luna-lang :End of /NAMES list.\r\n',
36-
)
37-
})
38-
}))
39-
})
26+
setImmediate(() => {
27+
stream.write(
28+
':pratchett.freenode.net 353 tjholowaychuk = #luna-lang :~owner @foo %halfop +bar baz\r\n',
29+
)
30+
stream.write(
31+
':pratchett.freenode.net 353 tjholowaychuk = #luna-lang :some more\r\n',
32+
)
33+
stream.write(
34+
':pratchett.freenode.net 366 tjholowaychuk #luna-lang :End of /NAMES list.\r\n',
35+
)
36+
})
37+
}))
4038

4139
it('should emit "names"', () =>
4240
new Promise((done) => {

test/nick.test.js

+20-22
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
1-
import { describe, it } from 'vitest'
1+
import { it } from 'vitest'
22
import 'should'
33

44
import irc from '..'
55
import { PassThrough as Stream } from 'stream'
66

7-
describe('on NICK', () => {
8-
it('should emit "nick"', () =>
9-
new Promise((done) => {
10-
var stream = new Stream()
11-
var client = irc(stream)
7+
it('should emit "nick"', () =>
8+
new Promise((done) => {
9+
var stream = new Stream()
10+
var client = irc(stream)
1211

13-
client.on('nick', function (e) {
14-
e.nick.should.eql('colinm')
15-
e.new.should.equal('cmilhench')
16-
e.hostmask.nick.should.equal('colinm')
17-
e.hostmask.username.should.equal('~colinm')
18-
e.hostmask.hostname.should.equal('host-92-17-247-88.as13285.net')
19-
e.hostmask.string.should.equal(
20-
'colinm!~colinm@host-92-17-247-88.as13285.net',
21-
)
22-
done()
23-
})
24-
25-
stream.write(
26-
':colinm!~colinm@host-92-17-247-88.as13285.net NICK :cmilhench\r\n',
12+
client.on('nick', function (e) {
13+
e.nick.should.eql('colinm')
14+
e.new.should.equal('cmilhench')
15+
e.hostmask.nick.should.equal('colinm')
16+
e.hostmask.username.should.equal('~colinm')
17+
e.hostmask.hostname.should.equal('host-92-17-247-88.as13285.net')
18+
e.hostmask.string.should.equal(
19+
'colinm!~colinm@host-92-17-247-88.as13285.net',
2720
)
28-
}))
29-
})
21+
done()
22+
})
23+
24+
stream.write(
25+
':colinm!~colinm@host-92-17-247-88.as13285.net NICK :cmilhench\r\n',
26+
)
27+
}))

0 commit comments

Comments
 (0)