-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
75a27b2
commit 9ac20fd
Showing
15 changed files
with
413 additions
and
473 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,21 +3,19 @@ import { expect, it } from 'vitest' | |
import irc from '..' | ||
import { PassThrough as Stream } from 'stream' | ||
|
||
it('should emit "invite"', () => | ||
new Promise((done) => { | ||
const stream = new Stream() | ||
const client = irc(stream) | ||
it('should emit "invite"', () => { | ||
const stream = new Stream() | ||
const client = irc(stream) | ||
|
||
client.on('invite', (e) => { | ||
expect(e.from).toStrictEqual('test') | ||
expect(e.to).toStrictEqual('astranger') | ||
expect(e.channel).toStrictEqual('#something') | ||
expect(e.hostmask.nick).toStrictEqual('test') | ||
expect(e.hostmask.username).toStrictEqual('~user') | ||
expect(e.hostmask.hostname).toStrictEqual('example.com') | ||
expect(e.hostmask.string).toStrictEqual('[email protected]') | ||
done() | ||
}) | ||
client.on('invite', (e) => { | ||
expect(e.from).toStrictEqual('test') | ||
expect(e.to).toStrictEqual('astranger') | ||
expect(e.channel).toStrictEqual('#something') | ||
expect(e.hostmask.nick).toStrictEqual('test') | ||
expect(e.hostmask.username).toStrictEqual('~user') | ||
expect(e.hostmask.hostname).toStrictEqual('example.com') | ||
expect(e.hostmask.string).toStrictEqual('[email protected]') | ||
}) | ||
|
||
stream.write(':[email protected] INVITE astranger :#something\r\n') | ||
})) | ||
stream.write(':[email protected] INVITE astranger :#something\r\n') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,26 +3,24 @@ import { expect, it } from 'vitest' | |
import irc from '..' | ||
import { PassThrough as Stream } from 'stream' | ||
|
||
it('should emit "join"', () => | ||
new Promise((done) => { | ||
const stream = new Stream() | ||
const client = irc(stream) | ||
it('should emit "join"', () => { | ||
const stream = new Stream() | ||
const client = irc(stream) | ||
|
||
client.on('join', (e) => { | ||
expect(e.nick).toStrictEqual('tjholowaychuk') | ||
expect(e.channel).toStrictEqual('#express') | ||
expect(e.hostmask.nick).toStrictEqual('tjholowaychuk') | ||
expect(e.hostmask.username).toStrictEqual('~tjholoway') | ||
expect(e.hostmask.hostname).toStrictEqual( | ||
'S01067cb21b2fd643.gv.shawcable.net', | ||
) | ||
expect(e.hostmask.string).toStrictEqual( | ||
'[email protected]', | ||
) | ||
done() | ||
}) | ||
|
||
stream.write( | ||
':[email protected] JOIN #express\r\n', | ||
client.on('join', (e) => { | ||
expect(e.nick).toStrictEqual('tjholowaychuk') | ||
expect(e.channel).toStrictEqual('#express') | ||
expect(e.hostmask.nick).toStrictEqual('tjholowaychuk') | ||
expect(e.hostmask.username).toStrictEqual('~tjholoway') | ||
expect(e.hostmask.hostname).toStrictEqual( | ||
'S01067cb21b2fd643.gv.shawcable.net', | ||
) | ||
expect(e.hostmask.string).toStrictEqual( | ||
'[email protected]', | ||
) | ||
})) | ||
}) | ||
|
||
stream.write( | ||
':[email protected] JOIN #express\r\n', | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,27 +3,25 @@ import { expect, it } from 'vitest' | |
import irc from '..' | ||
import { PassThrough as Stream } from 'stream' | ||
|
||
it('should emit "kick"', () => | ||
new Promise((done) => { | ||
const stream = new Stream() | ||
const client = irc(stream) | ||
it('should emit "kick"', () => { | ||
const stream = new Stream() | ||
const client = irc(stream) | ||
|
||
client.on('kick', (e) => { | ||
expect(e.nick).toStrictEqual('tjholowaychuk') | ||
expect(e.client).toStrictEqual('tobi') | ||
expect(e.channel).toStrictEqual('#express') | ||
expect(e.hostmask.nick).toStrictEqual('tjholowaychuk') | ||
expect(e.hostmask.username).toStrictEqual('~tjholoway') | ||
expect(e.hostmask.hostname).toStrictEqual( | ||
'S01067cb21b2fd643.gv.shawcable.net', | ||
) | ||
expect(e.hostmask.string).toStrictEqual( | ||
'[email protected]', | ||
) | ||
done() | ||
}) | ||
|
||
stream.write( | ||
':[email protected] KICK #express tobi :Too ferrety\r\n', | ||
client.on('kick', (e) => { | ||
expect(e.nick).toStrictEqual('tjholowaychuk') | ||
expect(e.client).toStrictEqual('tobi') | ||
expect(e.channel).toStrictEqual('#express') | ||
expect(e.hostmask.nick).toStrictEqual('tjholowaychuk') | ||
expect(e.hostmask.username).toStrictEqual('~tjholoway') | ||
expect(e.hostmask.hostname).toStrictEqual( | ||
'S01067cb21b2fd643.gv.shawcable.net', | ||
) | ||
expect(e.hostmask.string).toStrictEqual( | ||
'[email protected]', | ||
) | ||
})) | ||
}) | ||
|
||
stream.write( | ||
':[email protected] KICK #express tobi :Too ferrety\r\n', | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,89 +3,81 @@ import { expect, it } from 'vitest' | |
import irc from '..' | ||
import { PassThrough as Stream } from 'stream' | ||
|
||
it('should respond with user names', () => | ||
new Promise((done) => { | ||
const stream = new Stream() | ||
const client = irc(stream) | ||
it('should respond with user names', () => { | ||
const stream = new Stream() | ||
const client = irc(stream) | ||
|
||
client.names('#luna-lang', (err, names) => { | ||
if (err) return done(err) | ||
expect(names).toStrictEqual([ | ||
{ 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', (err, names) => { | ||
expect(err).toBeNull() | ||
expect(names).toStrictEqual([ | ||
{ name: 'owner', mode: '~' }, | ||
{ name: 'foo', mode: '@' }, | ||
{ name: 'halfop', mode: '%' }, | ||
{ name: 'bar', mode: '+' }, | ||
{ name: 'baz', mode: '' }, | ||
{ name: 'some', mode: '' }, | ||
{ name: 'more', mode: '' }, | ||
]) | ||
}) | ||
|
||
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', | ||
) | ||
}) | ||
})) | ||
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) => { | ||
const stream = new Stream() | ||
const client = irc(stream) | ||
it('should emit "names"', () => { | ||
const stream = new Stream() | ||
const client = irc(stream) | ||
|
||
client.on('names', (e) => { | ||
expect(e.channel).toStrictEqual('#luna-lang') | ||
expect(e.names).toStrictEqual([ | ||
{ name: 'one', mode: '' }, | ||
{ name: 'two', mode: '~' }, | ||
{ name: 'three', mode: '' }, | ||
{ name: 'foo', mode: '@' }, | ||
{ name: 'bar', mode: '@' }, | ||
{ name: 'baz', mode: '%' }, | ||
]) | ||
done() | ||
}) | ||
client.on('names', (e) => { | ||
expect(e.channel).toStrictEqual('#luna-lang') | ||
expect(e.names).toStrictEqual([ | ||
{ name: 'one', mode: '' }, | ||
{ name: 'two', mode: '~' }, | ||
{ name: 'three', mode: '' }, | ||
{ name: 'foo', mode: '@' }, | ||
{ name: 'bar', mode: '@' }, | ||
{ name: 'baz', mode: '%' }, | ||
]) | ||
}) | ||
|
||
stream.write(':[email protected] JOIN #luna-lang\r\n') | ||
stream.write( | ||
':rothfuss.freenode.net 353 tjholowaychuk = #luna-lang :one ~two three\r\n', | ||
) | ||
stream.write( | ||
':rothfuss.freenode.net 353 tjholowaychuk = #luna-lang :@foo @bar %baz\r\n', | ||
) | ||
stream.write( | ||
':rothfuss.freenode.net 366 tjholowaychuk #luna-lang :End of /NAMES list.\r\n', | ||
) | ||
})) | ||
stream.write(':[email protected] JOIN #luna-lang\r\n') | ||
stream.write( | ||
':rothfuss.freenode.net 353 tjholowaychuk = #luna-lang :one ~two three\r\n', | ||
) | ||
stream.write( | ||
':rothfuss.freenode.net 353 tjholowaychuk = #luna-lang :@foo @bar %baz\r\n', | ||
) | ||
stream.write( | ||
':rothfuss.freenode.net 366 tjholowaychuk #luna-lang :End of /NAMES list.\r\n', | ||
) | ||
}) | ||
|
||
it('should retain ~ / @ / % / +', () => | ||
new Promise((done) => { | ||
const stream = new Stream() | ||
const client = irc(stream) | ||
it('should retain ~ / @ / % / +', () => { | ||
const stream = new Stream() | ||
const client = irc(stream) | ||
|
||
client.on('names', (e) => { | ||
expect(e.channel).toStrictEqual('##luna-lang') | ||
expect(e.names).toStrictEqual([ | ||
{ name: 'owner', mode: '~' }, | ||
{ name: 'tjholowaychuk', mode: '@' }, | ||
{ name: 'halfop', mode: '%' }, | ||
{ name: 'tobi', mode: '+' }, | ||
]) | ||
done() | ||
}) | ||
client.on('names', (e) => { | ||
expect(e.channel).toStrictEqual('##luna-lang') | ||
expect(e.names).toStrictEqual([ | ||
{ name: 'owner', mode: '~' }, | ||
{ name: 'tjholowaychuk', mode: '@' }, | ||
{ name: 'halfop', mode: '%' }, | ||
{ name: 'tobi', mode: '+' }, | ||
]) | ||
}) | ||
|
||
stream.write(':[email protected] JOIN #luna-lang\r\n') | ||
stream.write( | ||
':rothfuss.freenode.net 353 tjholowaychuk @ ##luna-lang :~owner @tjholowaychuk %halfop +tobi\r\n', | ||
) | ||
stream.write( | ||
':rothfuss.freenode.net 366 tjholowaychuk ##luna-lang :End of /NAMES list.\r\n', | ||
) | ||
})) | ||
stream.write(':[email protected] JOIN #luna-lang\r\n') | ||
stream.write( | ||
':rothfuss.freenode.net 353 tjholowaychuk @ ##luna-lang :~owner @tjholowaychuk %halfop +tobi\r\n', | ||
) | ||
stream.write( | ||
':rothfuss.freenode.net 366 tjholowaychuk ##luna-lang :End of /NAMES list.\r\n', | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,24 +3,22 @@ import { expect, it } from 'vitest' | |
import irc from '..' | ||
import { PassThrough as Stream } from 'stream' | ||
|
||
it('should emit "nick"', () => | ||
new Promise((done) => { | ||
const stream = new Stream() | ||
const client = irc(stream) | ||
it('should emit "nick"', () => { | ||
const stream = new Stream() | ||
const client = irc(stream) | ||
|
||
client.on('nick', (e) => { | ||
expect(e.nick).toStrictEqual('colinm') | ||
expect(e.new).toStrictEqual('cmilhench') | ||
expect(e.hostmask.nick).toStrictEqual('colinm') | ||
expect(e.hostmask.username).toStrictEqual('~colinm') | ||
expect(e.hostmask.hostname).toStrictEqual('host-92-17-247-88.as13285.net') | ||
expect(e.hostmask.string).toStrictEqual( | ||
'[email protected]', | ||
) | ||
done() | ||
}) | ||
|
||
stream.write( | ||
':[email protected] NICK :cmilhench\r\n', | ||
client.on('nick', (e) => { | ||
expect(e.nick).toStrictEqual('colinm') | ||
expect(e.new).toStrictEqual('cmilhench') | ||
expect(e.hostmask.nick).toStrictEqual('colinm') | ||
expect(e.hostmask.username).toStrictEqual('~colinm') | ||
expect(e.hostmask.hostname).toStrictEqual('host-92-17-247-88.as13285.net') | ||
expect(e.hostmask.string).toStrictEqual( | ||
'[email protected]', | ||
) | ||
})) | ||
}) | ||
|
||
stream.write( | ||
':[email protected] NICK :cmilhench\r\n', | ||
) | ||
}) |
Oops, something went wrong.