-
Notifications
You must be signed in to change notification settings - Fork 14
/
test.js
77 lines (72 loc) · 1.97 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
"use strict";
require('./utils.js').installGlobals();
function runTest(master, testId) {
if (testId === '1') {
if (master.activeEntity.type === 'channel') {
master.user.applyStateChange('Join', master.activeEntity.entityId, {
nick: 'wezirc',
user: 'user',
host: 'host'
});
} else {
master.user.showError('Must be used in a channel');
}
} else if (testId === '2') {
if (master.activeEntity.type === 'channel') {
for (let i of indices(1000)) {
master.user.applyStateChange('Join', master.activeEntity.entityId, {
nick: 'u' + i,
user: 'user',
host: 'host'
});
}
} else {
master.user.showError('Must be used in a channel');
}
} else if (testId === '3') {
if (master.activeEntity.type === 'channel') {
master.user.applyStateChange('Join', master.activeEntity.entityId, {
nick: 'paulAWAY',
user: 'user',
host: 'host',
type: 'client'
});
master.user.applyStateChange('ChatMessage', master.activeEntity.entityId, {
nick: 'paulAWAY',
user: 'user',
host: 'host',
type: 'client'
}, 'test message');
master.user.applyStateChange('NickChange', master.activeEntity.server.entityId, 'paulAWAY', 'paul');
} else {
master.user.showError('Must be used in a channel');
}
} else if (testId === 'userdupes') {
if (master.activeEntity.type === 'channel') {
const channel = master.activeEntity;
const userlist = channel.userlist.slice(0);
userlist.sort(function(a, b) {
if (a.nick < b.nick) {
return -1;
} else if (a.nick > b.nick) {
return 1;
} else {
return 0;
}
});
let last = null;
let numDupes = 0;
userlist.forEach(function(entry) {
if (last != null && last == entry.nick) {
master.user.showInfo('Duplicate nick: ' + entry.nick);
numDupes++;
}
last = entry.nick;
});
master.user.showInfo('Dupes: ' + numDupes);
} else {
master.user.showError('Must be used in a channel');
}
}
}
module.exports.runTest = runTest;