From 1a12a8f31e19b843f542eb3be932d19ce84797e6 Mon Sep 17 00:00:00 2001 From: "Jeremy Wall (zaphar)" Date: Sat, 16 Nov 2013 13:27:56 -0500 Subject: [PATCH] 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. --- .hgignore | 1 + biblerefparsingtests.html | 93 --------------------------------------- package.json | 8 ++++ test/all.js | 61 +++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 93 deletions(-) delete mode 100644 biblerefparsingtests.html create mode 100644 package.json create mode 100644 test/all.js diff --git a/.hgignore b/.hgignore index 2e3c0eb7..5c72fa8a 100644 --- a/.hgignore +++ b/.hgignore @@ -4,3 +4,4 @@ DynamicBibleUtility/DynamicBibleUtility/obj *.suo *.orig Android/DynamicBible/bin +*node_modules* diff --git a/biblerefparsingtests.html b/biblerefparsingtests.html deleted file mode 100644 index c69f9166..00000000 --- a/biblerefparsingtests.html +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - - - - - - - The Bible with Strong's Numbers and Cross References - - - - - - - - diff --git a/package.json b/package.json new file mode 100644 index 00000000..bbcb57f0 --- /dev/null +++ b/package.json @@ -0,0 +1,8 @@ +{ + "name": "dynamicbible", + "description": "DynamicBible Dynamic HTML javascript", + "dependencies": {"requirejs": ">=2.1.9"}, + "scripts": {"test": "node test/all.js"}, + "files": ["./js"], + "devDependencies": {"test": ">=0.0.5"} +} diff --git a/test/all.js b/test/all.js new file mode 100644 index 00000000..58d9011c --- /dev/null +++ b/test/all.js @@ -0,0 +1,61 @@ +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);