Jeremy Wall (zaphar) 1a12a8f31e Setup unit testing infrastructure using npm
* Add package.json to tell npm what dependencies we need.
* Use npm's test package for the assertions
* Add a test/all.js as our test suite entrypoint.
* Port biblerefparsing tests over to the new unit test framework.
2013-11-16 13:27:56 -05:00

62 lines
2.4 KiB
JavaScript

var requirejs = require('requirejs');
requirejs.config({
baseUrl: 'js/',
nodeRequire: require
});
exports['test ref parsing'] = function(assert, done) {
requirejs(["reference"], function(r) {
var tests = [
["acts 1:4 - 60", "Acts 1:4 - 1:60"],
["acts 1:4 - *", "Acts 1:4 - 1:*"],
["acts 1:4 - 2:8", "Acts 1:4 - 2:8"],
["acts 1:4 - 1:8", "Acts 1:4 - 1:8"],
["acts 1:4 - 2", "Acts 1:4 - 1:4"],
["acts 1:4 - 8", "Acts 1:4 - 1:8"],
["acts 1:4-8", "Acts 1:4 - 1:8"],
["john 1:4 - john 2", "John 1:4 - 2:*"],
["john 1 : 4 - john 2", "John 1:4 - 2:*"],
["I john 1:4 - I john 2", "1 John 1:4 - 2:*"],
["1 john 1:4 - 1 john 2", "1 John 1:4 - 2:*"],
["1 john 1 : 4 - 1 john 2", "1 John 1:4 - 2:*"],
["1 john 3 - 1 john 5", "1 John 3:1 - 5:*"],
["1 John 1", "1 John 1:1 - 1:*"],
["John 1", "John 1:1 - 1:*"],
["1 John 1:1", "1 John 1:1 - 1:1"],
[" 1 John 1 : 1 ", "1 John 1:1 - 1:1"],
["John 1:1", "John 1:1 - 1:1"],
[" John 1 : 1 ", "John 1:1 - 1:1"],
[" 1 John 1 : 1 - 2 ", "1 John 1:1 - 1:2"],
["1 John 1:1-2", "1 John 1:1 - 1:2"],
["John 1:1-2", "John 1:1 - 1:2"],
["John 1 : 1 - 2", "John 1:1 - 1:2"],
["1 John 1 : 1 - 1 John 2 : 3 ", "1 John 1:1 - 2:3"],
["1 John 1:1-1 John 2:3", "1 John 1:1 - 2:3"],
["John 1:1-John 2:3", "John 1:1 - 2:3"],
["John 1 : 1 - John 2 : 3 ", "John 1:1 - 2:3"],
["John 1-2", "John 1:1 - 2:*"],
["John 1 - 2", "John 1:1 - 2:*"],
["1 John 1-2", "1 John 1:1 - 2:*"],
["1 John 1 - 2 ", "1 John 1:1 - 2:*"],
["John 3", "John 3:1 - 3:*"],
["John 2:1-John 3:3", "John 2:1 - 3:3"],
["John 2 : 1 - John 3 : 3 ", "John 2:1 - 3:3"],
["John 3-4", "John 3:1 - 4:*"],
["John 4 - 7", "John 4:1 - 7:*"],
["1 John 4-6", "1 John 4:1 - 6:*"],
["1 John 4 - 5 ", "1 John 4:1 - 5:*"]
];
for (var i = 0; i < tests.length; i++)
{
var t = tests[i];
var ref = r.Parse(t[0]);
var parsed = ref.bookname + " " + ref.startchapter + ":" + ref.startverse + " - " + ref.endchapter + ":" + ref.endverse;
assert.equal(parsed, t[1], parsed + " == " + t[1]);
}
done();
});
};
if (module == require.main) require('test').run(exports);