Skip to content

Commit ca392a0

Browse files
committed
tests: update tests
1 parent b477c6a commit ca392a0

File tree

8 files changed

+27
-23
lines changed

8 files changed

+27
-23
lines changed

test/authentication.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('handling authentication', () => {
1818
beforeEach(function() {
1919
// Initialize websocket server
2020
this.server = new WebSocketServer({ port: 7000 });
21-
this.client = new tmi.client({
21+
this.client = new tmi.Client({
2222
logger: {
2323
error: noop,
2424
info: noop

test/client.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,45 @@ const tmi = require('../index.js');
22

33
describe('client()', () => {
44
it('returns a new instance of itself', () => {
5-
const client = tmi.client();
6-
client.should.be.an.instanceOf(tmi.client);
5+
const client = tmi.Client();
6+
client.should.be.an.instanceOf(tmi.Client);
77
});
88

99
it('uses the \'info\' log when debug is set', () => {
10-
const client = new tmi.client({ options: { debug: true } });
10+
const client = new tmi.Client({ options: { debug: true } });
1111
client.should.be.ok();
1212
});
1313

1414
it('normalize channel names', () => {
15-
const client = new tmi.client({ channels: [ 'avalonstar', '#dayvemsee' ] });
15+
const client = new tmi.Client({ channels: [ 'avalonstar', '#dayvemsee' ] });
1616
client.opts.channels.should.eql([ '#avalonstar', '#dayvemsee' ]);
1717
});
1818

1919
it('should default secure to true when opts.connection.server and opts.connection.port not set', () => {
20-
let client = new tmi.client();
20+
let client = new tmi.Client();
2121
client.secure.should.eql(true);
22-
client = new tmi.client({ connection: {} });
22+
client = new tmi.Client({ connection: {} });
2323
client.secure.should.eql(true);
2424
});
2525
it('should default secure to false when opts.connection.server or opts.connection.port set', () => {
26-
let client = new tmi.client({ connection: { server: 'localhost' } });
26+
let client = new tmi.Client({ connection: { server: 'localhost' } });
2727
client.secure.should.eql(false);
28-
client = new tmi.client({ connection: { port: 1 } });
28+
client = new tmi.Client({ connection: { port: 1 } });
2929
client.secure.should.eql(false);
30-
client = new tmi.client({ connection: { server: 'localhost', port: 1 } });
30+
client = new tmi.Client({ connection: { server: 'localhost', port: 1 } });
3131
client.secure.should.eql(false);
3232
});
3333
});
3434

3535
describe('client getters', () => {
3636
it('gets options', () => {
3737
const opts = { options: { debug: true } };
38-
const client = new tmi.client(opts);
38+
const client = new tmi.Client(opts);
3939
client.getOptions().should.eql(opts);
4040
});
4141

4242
it('gets channels', () => {
43-
const client = new tmi.client();
43+
const client = new tmi.Client();
4444
client.getChannels().should.eql([]);
4545
});
4646
});

test/commands.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ describe('commands (justinfan)', () => {
408408
beforeEach(function() {
409409
// Initialize websocket server
410410
this.server = new WebSocketServer({ port: 7000 });
411-
this.client = new tmi.client({
411+
this.client = new tmi.Client({
412412
connection: {
413413
server: 'localhost',
414414
port: 7000,
@@ -574,7 +574,7 @@ describe('commands (identity)', () => {
574574
beforeEach(function() {
575575
// Initialize websocket server
576576
this.server = new WebSocketServer({ port: 7000 });
577-
this.client = new tmi.client({
577+
this.client = new tmi.Client({
578578
connection: {
579579
server: 'localhost',
580580
port: 7000
@@ -651,6 +651,7 @@ describe('commands (identity)', () => {
651651

652652
server.on('connection', ws => {
653653
ws.on('message', message => {
654+
message = message.toString();
654655
if(~message.indexOf('PRIVMSG')) {
655656
ws.send(`:tmi.twitch.tv PRIVMSG #local7000 :${message.split(':')[1]}`);
656657
}
@@ -680,6 +681,7 @@ describe('commands (identity)', () => {
680681

681682
server.on('connection', ws => {
682683
ws.on('message', message => {
684+
message = message.toString();
683685
if(~message.indexOf('PRIVMSG')) {
684686
ws.send(`:tmi.twitch.tv PRIVMSG #local7000 :${message.split(':')[1]}`);
685687
}

test/events.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ describe('client events', () => {
727727
events.forEach(e => {
728728
const { name, data, expected } = e;
729729
it(`emit ${name}`, cb => {
730-
const client = new tmi.client();
730+
const client = new tmi.Client();
731731

732732
client.on(name, (...args) => {
733733
'Reach this callback'.should.be.ok();
@@ -747,7 +747,7 @@ describe('client events', () => {
747747
});
748748

749749
it('emits disconnected', cb => {
750-
const client = new tmi.client();
750+
const client = new tmi.Client();
751751

752752
client.on('disconnected', reason => {
753753
reason.should.be.exactly('Connection closed.').and.be.a.String();

test/invalid.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const tests = [
1111
describe('invalid server events', () => {
1212
tests.forEach(test => {
1313
it(`treat "${test}" as invalid`, () => {
14-
const client = new tmi.client({
14+
const client = new tmi.Client({
1515
logger: {
1616
warn(message) {
1717
message.includes('Could not parse').should.be.ok;

test/logger.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ const _ = require('../lib/utils.js');
55

66
describe('client()', () => {
77
it('defaults to the stock logger', () => {
8-
const client = new tmi.client();
8+
const client = new tmi.Client();
99

1010
client.log.should.be.ok();
1111
});
1212

1313
it('allows a custom logger', () => {
14-
const client = new tmi.client({
14+
const client = new tmi.Client({
1515
logger: console
1616
});
1717

test/noop.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('no-op server events', () => {
2121
'Should not call this'.should.not.be.ok();
2222
};
2323

24-
const client = new tmi.client({
24+
const client = new tmi.Client({
2525
logger: {
2626
trace: stopTest,
2727
debug: stopTest,

test/websockets.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('websockets', () => {
1111
before(function() {
1212
// Initialize websocket server
1313
this.server = new WebSocketServer({ port: 7000 });
14-
this.client = new tmi.client({
14+
this.client = new tmi.Client({
1515
connection: {
1616
server: 'localhost',
1717
port: 7000
@@ -57,7 +57,7 @@ describe('server crashed, with reconnect: true (default)', () => {
5757
before(function() {
5858
// Initialize websocket server
5959
this.server = new WebSocketServer({ port: 7000 });
60-
this.client = new tmi.client({
60+
this.client = new tmi.Client({
6161
connection: {
6262
server: 'localhost',
6363
port: 7000
@@ -72,6 +72,7 @@ describe('server crashed, with reconnect: true (default)', () => {
7272
server.on('connection', _ws => {
7373
// Uh-oh, the server dies
7474
server.close();
75+
_ws.terminate();
7576
});
7677

7778
client.on('disconnected', () => {
@@ -89,7 +90,7 @@ describe('server crashed, with reconnect: false', () => {
8990
before(function() {
9091
// Initialize websocket server
9192
this.server = new WebSocketServer({ port: 7000 });
92-
this.client = new tmi.client({
93+
this.client = new tmi.Client({
9394
connection: {
9495
server: 'localhost',
9596
port: 7000,
@@ -105,6 +106,7 @@ describe('server crashed, with reconnect: false', () => {
105106
server.on('connection', _ws => {
106107
// Uh-oh, the server dies
107108
server.close();
109+
_ws.terminate();
108110
});
109111

110112
client.on('disconnected', () => {

0 commit comments

Comments
 (0)