add a test for twitch IRC parser
parent
684bf10332
commit
94c5aadb86
@ -0,0 +1,87 @@
|
||||
var TwitchChat = require('../TwitchChat');
|
||||
|
||||
var tests = [{
|
||||
input: '@badge-info=subscriber/1;badges=subscriber/0,premium/1;color=#5F9EA0;display-name=bloodvale08;emotes=;flags=;id=63ab3381-076b-4176-a495-22f8f9b6b09c;mod=0;room-id=197406569;subscriber=1;tmi-sent-ts=1609721077028;turbo=0;user-id=41319751;user-type= :bloodvale08!bloodvale08@bloodvale08.tmi.twitch.tv PRIVMSG #thenicolet :so what every one has a stretch mark',
|
||||
expect: {
|
||||
vars: {
|
||||
badgeInfo: 'subscriber/1',
|
||||
badges: 'subscriber/0,premium/1',
|
||||
color: '#5F9EA0',
|
||||
displayName: 'bloodvale08',
|
||||
emotes: '',
|
||||
flags: '',
|
||||
id: '63ab3381-076b-4176-a495-22f8f9b6b09c',
|
||||
mod: '0',
|
||||
roomId: '197406569',
|
||||
subscriber: '1',
|
||||
tmiSentTs: '1609721077028',
|
||||
turbo: '0',
|
||||
userId: '41319751',
|
||||
userType: ''
|
||||
},
|
||||
sender: {
|
||||
string: 'bloodvale08!bloodvale08@bloodvale08.tmi.twitch.tv',
|
||||
nick: 'bloodvale08',
|
||||
user: 'bloodvale08',
|
||||
host: 'bloodvale08.tmi.twitch.tv'
|
||||
},
|
||||
command: 'PRIVMSG',
|
||||
target: '#thenicolet',
|
||||
params: null,
|
||||
text: 'so what every one has a stretch mark'
|
||||
}
|
||||
}, {
|
||||
input: ':tmi.twitch.tv CAP * ACK :twitch.tv/tags twitch.tv/commands',
|
||||
expect: {
|
||||
vars: {},
|
||||
sender: {
|
||||
string: 'tmi.twitch.tv',
|
||||
nick: null,
|
||||
user: null,
|
||||
host: 'tmi.twitch.tv'
|
||||
},
|
||||
command: 'CAP',
|
||||
target: '*',
|
||||
params: 'ACK ',
|
||||
text: 'twitch.tv/tags twitch.tv/commands'
|
||||
}
|
||||
}, {
|
||||
input: 'PONG :tmi.twitch.tv',
|
||||
expect: {
|
||||
vars: {},
|
||||
sender: { string: null, nick: null, user: null, host: null },
|
||||
command: 'PONG',
|
||||
target: null,
|
||||
params: null,
|
||||
text: 'tmi.twitch.tv'
|
||||
}
|
||||
}, {
|
||||
input: ':windmillofpeace!windmillofpeace@windmillofpeace.tmi.twitch.tv JOIN #thenicolet',
|
||||
expect: {
|
||||
vars: {},
|
||||
sender: {
|
||||
string: 'windmillofpeace!windmillofpeace@windmillofpeace.tmi.twitch.tv',
|
||||
nick: 'windmillofpeace',
|
||||
user: 'windmillofpeace',
|
||||
host: 'windmillofpeace.tmi.twitch.tv'
|
||||
},
|
||||
command: 'JOIN',
|
||||
target: '#thenicolet',
|
||||
params: null,
|
||||
text: null
|
||||
}
|
||||
}];
|
||||
|
||||
var t = new TwitchChat();
|
||||
|
||||
for(let test of tests) {
|
||||
var expect = test.expect;
|
||||
var got = t.parseIRCLine(test.input);
|
||||
|
||||
if(JSON.stringify(expect) == JSON.stringify(got)) {
|
||||
console.log('PASS', test.input);
|
||||
} else {
|
||||
console.log('\033[31mFAIL\033[0m', '\033[31minput =\033[0m', test.input, '\033[31mexpected =\033[0m', expect, '\033[31mgot =\033[0m', got);
|
||||
break;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue