Skip to content

Commit

Permalink
test: Avoid the use of describe
Browse files Browse the repository at this point in the history
  • Loading branch information
simnalamburt committed Oct 8, 2024
1 parent 18e1c73 commit e36bc24
Show file tree
Hide file tree
Showing 14 changed files with 423 additions and 453 deletions.
26 changes: 12 additions & 14 deletions test/away.test.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
import { describe, it } from 'vitest'
import { it } from 'vitest'
import 'should'

import irc from '..'
import { PassThrough as Stream } from 'stream'

describe('on RPL_AWAY', () => {
it('should emit "away"', () =>
new Promise((done) => {
var stream = new Stream()
var client = irc(stream)
it('should emit "away"', () =>
new Promise((done) => {
var stream = new Stream()
var client = irc(stream)

client.on('away', function (e) {
e.nick.should.equal('colinm')
e.message.should.eql('brb food time')
done()
})
client.on('away', function (e) {
e.nick.should.equal('colinm')
e.message.should.eql('brb food time')
done()
})

stream.write(':irc.host.net 301 me colinm :brb food time\r\n')
}))
})
stream.write(':irc.host.net 301 me colinm :brb food time\r\n')
}))
36 changes: 17 additions & 19 deletions test/invite.test.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
import { describe, it } from 'vitest'
import { it } from 'vitest'
import 'should'

import irc from '..'
import { PassThrough as Stream } from 'stream'

describe('on INVITE', () => {
it('should emit "invite"', () =>
new Promise((done) => {
var stream = new Stream()
var client = irc(stream)
it('should emit "invite"', () =>
new Promise((done) => {
var stream = new Stream()
var client = irc(stream)

client.on('invite', function (e) {
e.from.should.equal('test')
e.to.should.equal('astranger')
e.channel.should.equal('#something')
e.hostmask.nick.should.equal('test')
e.hostmask.username.should.equal('~user')
e.hostmask.hostname.should.equal('example.com')
e.hostmask.string.should.equal('[email protected]')
done()
})
client.on('invite', function (e) {
e.from.should.equal('test')
e.to.should.equal('astranger')
e.channel.should.equal('#something')
e.hostmask.nick.should.equal('test')
e.hostmask.username.should.equal('~user')
e.hostmask.hostname.should.equal('example.com')
e.hostmask.string.should.equal('[email protected]')
done()
})

stream.write(':[email protected] INVITE astranger :#something\r\n')
}))
})
stream.write(':[email protected] INVITE astranger :#something\r\n')
}))
42 changes: 20 additions & 22 deletions test/join.test.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
import { describe, it } from 'vitest'
import { it } from 'vitest'
import 'should'

import irc from '..'
import { PassThrough as Stream } from 'stream'

describe('on JOIN', () => {
it('should emit "join"', () =>
new Promise((done) => {
var stream = new Stream()
var client = irc(stream)
it('should emit "join"', () =>
new Promise((done) => {
var stream = new Stream()
var client = irc(stream)

client.on('join', function (e) {
e.nick.should.equal('tjholowaychuk')
e.channel.should.equal('#express')
e.hostmask.nick.should.equal('tjholowaychuk')
e.hostmask.username.should.equal('~tjholoway')
e.hostmask.hostname.should.equal('S01067cb21b2fd643.gv.shawcable.net')
e.hostmask.string.should.equal(
'[email protected]',
)
done()
})

stream.write(
':[email protected] JOIN #express\r\n',
client.on('join', function (e) {
e.nick.should.equal('tjholowaychuk')
e.channel.should.equal('#express')
e.hostmask.nick.should.equal('tjholowaychuk')
e.hostmask.username.should.equal('~tjholoway')
e.hostmask.hostname.should.equal('S01067cb21b2fd643.gv.shawcable.net')
e.hostmask.string.should.equal(
'[email protected]',
)
}))
})
done()
})

stream.write(
':[email protected] JOIN #express\r\n',
)
}))
44 changes: 21 additions & 23 deletions test/kick.test.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
import { describe, it } from 'vitest'
import { it } from 'vitest'
import 'should'

import irc from '..'
import { PassThrough as Stream } from 'stream'

describe('on KICK', () => {
it('should emit "kick"', () =>
new Promise((done) => {
var stream = new Stream()
var client = irc(stream)
it('should emit "kick"', () =>
new Promise((done) => {
var stream = new Stream()
var client = irc(stream)

client.on('kick', function (e) {
e.nick.should.equal('tjholowaychuk')
e.client.should.equal('tobi')
e.channel.should.eql('#express')
e.hostmask.nick.should.equal('tjholowaychuk')
e.hostmask.username.should.equal('~tjholoway')
e.hostmask.hostname.should.equal('S01067cb21b2fd643.gv.shawcable.net')
e.hostmask.string.should.equal(
'[email protected]',
)
done()
})

stream.write(
':[email protected] KICK #express tobi :Too ferrety\r\n',
client.on('kick', function (e) {
e.nick.should.equal('tjholowaychuk')
e.client.should.equal('tobi')
e.channel.should.eql('#express')
e.hostmask.nick.should.equal('tjholowaychuk')
e.hostmask.username.should.equal('~tjholoway')
e.hostmask.hostname.should.equal('S01067cb21b2fd643.gv.shawcable.net')
e.hostmask.string.should.equal(
'[email protected]',
)
}))
})
done()
})

stream.write(
':[email protected] KICK #express tobi :Too ferrety\r\n',
)
}))
62 changes: 30 additions & 32 deletions test/names.test.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,40 @@
import { describe, it } from 'vitest'
import { it } from 'vitest'
import 'should'

import irc from '..'
import { PassThrough as Stream } from 'stream'

describe('client.names(chan, fn)', () => {
it('should respond with user names', () =>
new Promise((done) => {
var stream = new Stream()
var client = irc(stream)
it('should respond with user names', () =>
new Promise((done) => {
var stream = new Stream()
var client = irc(stream)

client.names('#luna-lang', function (err, names) {
if (err) return done(err)
names.should.eql([
{ name: 'owner', mode: '~' },
{ name: 'foo', mode: '@' },
{ name: 'halfop', mode: '%' },
{ name: 'bar', mode: '+' },
{ name: 'baz', mode: '' },
{ name: 'some', mode: '' },
{ name: 'more', mode: '' },
])
done()
})
client.names('#luna-lang', function (err, names) {
if (err) return done(err)
names.should.eql([
{ name: 'owner', mode: '~' },
{ name: 'foo', mode: '@' },
{ name: 'halfop', mode: '%' },
{ name: 'bar', mode: '+' },
{ name: 'baz', mode: '' },
{ name: 'some', mode: '' },
{ name: 'more', mode: '' },
])
done()
})

setImmediate(() => {
stream.write(
':pratchett.freenode.net 353 tjholowaychuk = #luna-lang :~owner @foo %halfop +bar baz\r\n',
)
stream.write(
':pratchett.freenode.net 353 tjholowaychuk = #luna-lang :some more\r\n',
)
stream.write(
':pratchett.freenode.net 366 tjholowaychuk #luna-lang :End of /NAMES list.\r\n',
)
})
}))
})
setImmediate(() => {
stream.write(
':pratchett.freenode.net 353 tjholowaychuk = #luna-lang :~owner @foo %halfop +bar baz\r\n',
)
stream.write(
':pratchett.freenode.net 353 tjholowaychuk = #luna-lang :some more\r\n',
)
stream.write(
':pratchett.freenode.net 366 tjholowaychuk #luna-lang :End of /NAMES list.\r\n',
)
})
}))

it('should emit "names"', () =>
new Promise((done) => {
Expand Down
42 changes: 20 additions & 22 deletions test/nick.test.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
import { describe, it } from 'vitest'
import { it } from 'vitest'
import 'should'

import irc from '..'
import { PassThrough as Stream } from 'stream'

describe('on NICK', () => {
it('should emit "nick"', () =>
new Promise((done) => {
var stream = new Stream()
var client = irc(stream)
it('should emit "nick"', () =>
new Promise((done) => {
var stream = new Stream()
var client = irc(stream)

client.on('nick', function (e) {
e.nick.should.eql('colinm')
e.new.should.equal('cmilhench')
e.hostmask.nick.should.equal('colinm')
e.hostmask.username.should.equal('~colinm')
e.hostmask.hostname.should.equal('host-92-17-247-88.as13285.net')
e.hostmask.string.should.equal(
'[email protected]',
)
done()
})

stream.write(
':[email protected] NICK :cmilhench\r\n',
client.on('nick', function (e) {
e.nick.should.eql('colinm')
e.new.should.equal('cmilhench')
e.hostmask.nick.should.equal('colinm')
e.hostmask.username.should.equal('~colinm')
e.hostmask.hostname.should.equal('host-92-17-247-88.as13285.net')
e.hostmask.string.should.equal(
'[email protected]',
)
}))
})
done()
})

stream.write(
':[email protected] NICK :cmilhench\r\n',
)
}))
Loading

0 comments on commit e36bc24

Please sign in to comment.