Skip to content
Browse files

added some tests

  • Loading branch information...
1 parent 64137d0 commit bd221c883544a8c452d72ea03f40ed06edabea0a @jedp committed May 24, 2011
Showing with 54 additions and 0 deletions.
  1. +1 −0 package.json
  2. +53 −0 test/test-completer.js
View
1 package.json
@@ -20,6 +20,7 @@
"express": "",
"hiredis": "",
"jade": "",
+ "nodeunit": "",
"now": "",
"redis": "",
"underscore": ""
View
53 test/test-completer.js
@@ -0,0 +1,53 @@
+var completer = require('../completer');
+var testCase = require('nodeunit').testCase;
+
+completer.applicationPrefix('_test');
+completer.addCompletions("I like pie", 'glug', 42);
+completer.addCompletions("I like potatoes", 'merg', 17);
+
+module.exports = testCase({
+ setUp: function(callback) {
+ callback();
+ },
+
+ tearDown: function(callback) {
+ // so ... someday there will be a remove() function, right?
+ callback();
+ },
+
+ "word completions": function(test) {
+ test.expect(1);
+ completer.getWordCompletions('pot', 10, function(err, compls) {
+ test.ok(compls[0] === 'potatoes');
+ test.done();
+ });
+ },
+
+ "phrase completions": function(test) {
+ test.expect(2);
+ completer.getPhraseCompletions('like pi', 10, function(err, compls) {
+ test.ok(compls[0] === 'like');
+ test.ok(compls[1] === 'pie');
+ test.done();
+ });
+ },
+
+ "search": function(test) {
+ test.expect(3);
+
+ completer.search("I like", 10, function(err, compls) {
+ if (err) throw err;
+ test.ok(compls.length === 2);
+
+ completer.search("potatoes", 10, function(err, compls) {
+ if (err) throw err;
+ test.ok(compls.length === 1);
+ test.ok(compls[0] === "merg:I like potatoes")
+
+ test.done();
+ });
+ });
+ }
+
+
+});

0 comments on commit bd221c8

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