Permalink
Browse files

Fixed encoder and added encoding tests. Now at 100% test coverage for…

… data.js

Added .swo to gitignore
  • Loading branch information...
1 parent db03ea2 commit 07e07442f3ed963d3fd0c37a6b8f8d5219a2f821 @rauchg rauchg committed Nov 12, 2010
Showing with 7 additions and 1 deletion.
  1. +1 −0 .gitignore
  2. +1 −1 lib/socket.io/data.js
  3. +5 −0 tests/data.js
View
@@ -7,3 +7,4 @@ lib-cov
*.out
*.pid.swp
*.swp
+*.swo
View
@@ -118,7 +118,7 @@ function encode(messages){
for (var i = 0, str; i < messages.length; i++){
str = messages[i][1];
if (str === undefined || str === null || str === false) str = '';
- ret += msg[0] + ':' + msg[1].length + ':' + msg[1] + ',';
+ ret += messages[i][0] + ':' + str.length + ':' + str + ',';
}
return ret;
}
View
@@ -165,6 +165,11 @@ module.exports = {
assert.ok(errors === 1);
assert.ok(error === 'Termination character "," expected');
});
+ },
+
+ 'test encoding': function(assert){
+ assert.ok(encode([3,'Testing']) == '3:7:Testing,');
+ assert.ok(encode([[1,''],[2,'tobi']]) == '1:0:,2:4:tobi,');
}
};

0 comments on commit 07e0744

Please sign in to comment.