Permalink
Browse files

using tape

  • Loading branch information...
substack committed Dec 12, 2012
1 parent 8193c7d commit 6adfdd7f45f1ee56e433cba8a23d4fa3e9b8707b
Showing with 39 additions and 35 deletions.
  1. +0 −1 index.js
  2. +11 −10 package.json
  3. +28 −24 test/codes.js
View
@@ -1,4 +1,3 @@
-var fs = require('fs');
var entities = require('./entities.json');
var revEntities = {};
View
@@ -1,10 +1,10 @@
{
- "name": "ent",
- "description": "Encode and decode HTML entities",
- "version": "0.0.4",
- "repository": "https://github.com/substack/node-ent.git",
- "author": "James Halliday <mail@substack.net> (http://substack.net)",
- "main": "./index.js",
+ "name" : "ent",
+ "description" : "Encode and decode HTML entities",
+ "version" : "0.0.5",
+ "repository" : "https://github.com/substack/node-ent.git",
+ "author" : "James Halliday <mail@substack.net> (http://substack.net)",
+ "main" : "./index.js",
"keywords" : [
"entities",
"entitify",
@@ -14,10 +14,11 @@
"decode"
],
"license" : "perl",
- "scripts": {
- "test": "expresso"
+ "scripts" : {
+ "test" : "tap test/*.js"
},
- "engines": {
- "node" : ">=0.2.0"
+ "devDependencies" : {
+ "tap" : "~0.3.3",
+ "tape" : "~0.1.0"
}
}
View
@@ -1,40 +1,43 @@
-var assert = require('assert');
+var test = require('tape');
var ent = require('ent');
-exports.amp = function () {
+test('amp', function (t) {
var a = 'a & b & c';
var b = 'a &amp; b &amp; c';
- assert.eql(ent.encode(a), b);
- assert.eql(ent.decode(b), a);
-};
+ t.equal(ent.encode(a), b);
+ t.equal(ent.decode(b), a);
+ t.end();
+});
-exports.html = function () {
+test('html', function (t) {
var a = '<html> © π " \'';
var b = '&lt;html&gt; &copy; &pi; &quot; &apos;';
- assert.eql(ent.encode(a), b);
- assert.eql(ent.decode(b), a);
-};
+ t.equal(ent.encode(a), b);
+ t.equal(ent.decode(b), a);
+ t.end();
+});
-exports.num = function () {
+test('num', function (t) {
var a = String.fromCharCode(1337);
var b = '&#1337;';
- assert.eql(ent.encode(a), b);
- assert.eql(ent.decode(b), a);
+ t.equal(ent.encode(a), b);
+ t.equal(ent.decode(b), a);
- assert.eql(ent.encode(a + a), b + b);
- assert.eql(ent.decode(b + b), a + a);
-};
+ t.equal(ent.encode(a + a), b + b);
+ t.equal(ent.decode(b + b), a + a);
+ t.end();
+});
-exports.hex = function () {
+test('hex', function (t) {
for (var i = 0; i < 32; i++) {
var a = String.fromCharCode(i);
if (a.match(/\s/)) {
- assert.equal(ent.decode(a), a);
+ t.equal(ent.decode(a), a);
}
else {
var b = '&#x' + i.toString(16) + ';';
- assert.equal(ent.decode(b), a);
- assert.equal(ent.encode(a), '&#' + i + ';');
+ t.equal(ent.decode(b), a);
+ t.equal(ent.encode(a), '&#' + i + ';');
}
}
@@ -43,14 +46,15 @@ exports.hex = function () {
var b = '&#x' + i.toString(16) + ';';
var c = '&#X' + i.toString(16) + ';';
- assert.equal(ent.decode(b), a);
- assert.equal(ent.decode(c), a);
+ t.equal(ent.decode(b), a);
+ t.equal(ent.decode(c), a);
var encoded = ent.encode(a);
var encoded2 = ent.encode(a + a);
if (!encoded.match(/^&\w+;/)) {
- assert.equal(encoded, '&#' + i + ';');
- assert.equal(encoded2, '&#' + i + ';&#' + i + ';');
+ t.equal(encoded, '&#' + i + ';');
+ t.equal(encoded2, '&#' + i + ';&#' + i + ';');
}
}
-};
+ t.end();
+});

0 comments on commit 6adfdd7

Please sign in to comment.