dynamicbible/test/ref-tests.js
Jeremy Wall (zaphar) 9125607faf Split out the unittests into separate files.
We use nodes require so we have to follow nodes module conventions for test
suites.

* As a result we need to inject the requirejs loader as well as the exports
  object.
* Also we need to move the requirejs setup logic into it's own module
  for reuse.
* The test modules add tests to the exports object for our test runner.
2013-11-16 15:26:49 -05:00

64 lines
2.6 KiB
JavaScript

var requirejs = require('./require-injector').requirejs;
var init = function(exports) {
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();
});
}
};
module.exports = {init: init};
if (module == require.main) {
init(exports);
require('test').run(exports);
}