Permalink
Browse files

Add node.js tests

  • Loading branch information...
1 parent 54a979a commit 2457f5ff522d371b2fba667335015b6844d3e3f5 @alcuadrado committed Aug 23, 2012
Showing with 60 additions and 2 deletions.
  1. +6 −2 package.json
  2. 0 test.html → test/browser_test.html
  3. +54 −0 test/node_test.js
View
@@ -4,7 +4,8 @@
"author": "Patricio Palladino <email@patriciopalladino.com>",
"version": "0.1.0",
"dependencies": {
- "commander": ">= 1.0.0"
+ "commander": "1.0.0",
+ "expresso": "0.9.0"
},
"bin": {
"hieroglyphy": "./bin/hieroglyphy"
@@ -14,5 +15,8 @@
"type": "git",
"url": "https://github.com/alcuadrado/hieroglyphy"
},
- "license": "MIT"
+ "license": "MIT",
+ "scripts": {
+ "test": "expresso test/node_test.js"
+ }
}
File renamed without changes.
View
@@ -0,0 +1,54 @@
+var hieroglyphy = require("../hieroglyphy"),
+ assert = require('assert');
+
+global.location = "http://example.com";
+global.testString = "foo";
+
+exports.testHieroglyphyCharacters = function () {
+ "use strict";
+
+ var i,
+ c,
+ encoded,
+ evaled;
+
+ for (i = 0; i < 127; i += 1) {
+ c = String.fromCharCode(i);
+ encoded = hieroglyphy.hieroglyphyString(c);
+ evaled = eval(encoded);
+
+ assert.equal(c, evaled);
+ assert.type(evaled, 'string');
+ }
+};
+
+exports.testHieroglyphyNumbers = function () {
+ "use strict";
+
+ var i,
+ encoded,
+ evaled;
+
+ for (i = 0; i < 1000; i += 1) {
+ encoded = hieroglyphy.hieroglyphyNumber(i);
+ evaled = eval(encoded);
+
+ assert.equal(i, evaled);
+ assert.type(evaled, 'number');
+ }
+};
+
+
+exports.testHieroglyphyScript = function () {
+ "use strict";
+
+ var encoded,
+ script;
+
+ //a script doing something (with some unicode)
+ script = "global.testString = \"bαr\"";
+
+ assert.equal(global.testString, "foo");
+ eval(hieroglyphy.hieroglyphyScript(script));
+ assert.equal(global.testString, "bαr");
+};

0 comments on commit 2457f5f

Please sign in to comment.