Skip to content
Browse files

Add failing unit test, add trim() to make test pass

  • Loading branch information...
1 parent 462b5d4 commit 83c80b69aa0d0f1435c9c9c72a7722f65bb5ab25 @metalbot metalbot committed
Showing with 31 additions and 3 deletions.
  1. +1 −1 lib/message.js
  2. +16 −1 test-src/message.sjs
  3. +14 −1 test/message.js
View
2 lib/message.js
@@ -128,7 +128,7 @@ var extensions = {
// :<server> 353 <me> = <channel> :<nicknames>
message.replyname = "RPL_NAMREPLY";
message.channel = message.params[2];
- message.nicknames = message.params[3].split(" ");
+ message.nicknames = message.params[3].trim().split(" ");
},
"366": function (message) {
View
17 test-src/message.sjs
@@ -15,6 +15,9 @@ var arg1 = 'arg-1';
var arg2 = 'arg-2';
var restargs = 'rest arguments';
var reason = 'Because I want to.';
+var nick1 = "adam";
+var nick2 = "beatrice";
+var nick3 = "charlie";
var messages = {
generic: format('GENERIC'),
@@ -33,7 +36,8 @@ var messages = {
part_reason: format(':%s PART %s :%s', hostmask, channel, reason),
quit: format(':%s QUIT', hostmask),
- quit_reason: format(':%s QUIT :%s', hostmask, reason)
+ quit_reason: format(':%s QUIT :%s', hostmask, reason),
+ a_353_with_whitespace: format(':%s 353 %s = %s :%s %s %s ', server, nickname, channel, nick1, nick2, nick3)
};
describe 'Message' {
@@ -168,5 +172,16 @@ describe 'Message' {
assert(message.hasOwnProperty('reason'));
}
}
+
+ describe '353:' {
+ it 'creates correct nicknames array' {
+ var message = Message(messages.a_353_with_whitespace, receiver);
+
+ assert(message.nicknames.length === 3);
+ assert(message.nicknames[0] === "adam");
+ assert(message.nicknames[1] === "beatrice");
+ assert(message.nicknames[2] === "charlie");
+ }
+ }
}
}
View
15 test/message.js
@@ -20,6 +20,9 @@ var arg1 = 'arg-1';
var arg2 = 'arg-2';
var restargs = 'rest arguments';
var reason = 'Because I want to.';
+var nick1 = 'adam';
+var nick2 = 'beatrice';
+var nick3 = 'charlie';
var messages = {
generic: format('GENERIC'),
generic_args: format('GENERIC %s %s :%s', arg1, arg2, restargs),
@@ -33,7 +36,8 @@ var messages = {
part: format(':%s PART %s', hostmask, channel),
part_reason: format(':%s PART %s :%s', hostmask, channel, reason),
quit: format(':%s QUIT', hostmask),
- quit_reason: format(':%s QUIT :%s', hostmask, reason)
+ quit_reason: format(':%s QUIT :%s', hostmask, reason),
+ a_353_with_whitespace: format(':%s 353 %s = %s :%s %s %s ', server, nickname, channel, nick1, nick2, nick3)
};
describe('Message', function () {
describe('common properties', function () {
@@ -155,5 +159,14 @@ describe('Message', function () {
assert(message.hasOwnProperty('reason'));
});
});
+ describe('353:', function () {
+ it('creates correct nicknames array', function () {
+ var message = Message(messages.a_353_with_whitespace, receiver);
+ assert(message.nicknames.length === 3);
+ assert(message.nicknames[0] === 'adam');
+ assert(message.nicknames[1] === 'beatrice');
+ assert(message.nicknames[2] === 'charlie');
+ });
+ });
});
});

0 comments on commit 83c80b6

Please sign in to comment.
Something went wrong with that request. Please try again.