This repository has been archived by the owner on Dec 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.js
86 lines (80 loc) · 2.13 KB
/
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
const chai = require('chai');
const tmi = require('tmi.js');
const lib = require('./lib');
const mathjs = require('mathjs');
const { expect } = chai;
const options = {
options: {
debug: false
},
connection: {
reconnect: true
},
channels: ['#ian678']
};
const client = tmi.client(options);
describe('Library', () => {
it('lib.stringToHex("Kappa 123") should return "4b6170706120313233"', () => {
expect(lib.stringToHex('Kappa 123').replace(/\\x/g, '')).to.equal('4b6170706120313233');
});
it('lib.msToTimeString(<1000) should return ""', () => {
expect(lib.msToTimeString(1)).to.equal('');
expect(lib.msToTimeString(500)).to.equal('');
expect(lib.msToTimeString(999)).to.equal('');
});
it('lib.msToTimeString(1000) should return "1 second"', () => {
expect(lib.msToTimeString(1000)).to.equal('1 second');
});
});
describe('TMI.js', () => {
it('Test connect', () => {
client.connect().catch(err => {
expect(err).to.equal(undefined);
});
client.disconnect().catch(err => {
expect(err).to.equal(undefined);
});
});
it('Test disconnect', () => {
client.connect().catch(err => {
expect(err).to.equal(undefined);
});
client.disconnect().catch(err => {
expect(err).to.equal(undefined);
});
});
});
describe('MATH', () => {
describe('mathjs', () => {
it('1+1**2-4 === -2', () => {
try {
expect(mathjs.eval('1+1^2-4')).to.equal(-2);
} catch (err) {
expect(err).to.equal(undefined);
}
});
});
describe('node', () => {
it('1+1**2-4 === -2', () => {
try {
expect((1 + (1 ** 2)) - 4).to.equal(-2);
} catch (err) {
expect(err).to.equal(undefined);
}
});
});
});
describe('Twitch API', () => {
describe('Get ID by username', () => {
it('nuuls => 100229878', async () => {
const id = await lib.getUser.id('nuuls');
expect(id).to.eql('100229878');
});
});
describe('Get data by id', () => {
it('100229878 => nuuls', async () => {
const data = await lib.getUser.data('100229878');
expect(data.stream.channel.name).to.eql('nuuls');
});
});
});