mirror of
https://gitlab.com/walljm/dynamicbible.git
synced 2025-07-25 00:09:54 -04:00
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.
This commit is contained in:
parent
c1da5e6324
commit
1a12a8f31e
@ -4,3 +4,4 @@ DynamicBibleUtility/DynamicBibleUtility/obj
|
||||
*.suo
|
||||
*.orig
|
||||
Android/DynamicBible/bin
|
||||
*node_modules*
|
||||
|
@ -1,93 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
||||
<meta name="author" content="Jason Wall" />
|
||||
<meta name="PBO.auth" content="8bff0c5d7a8f61d1e5dfa6c58da67c2b" />
|
||||
<meta name="geo.country" content="US" />
|
||||
<meta name="dc.language" content="en" />
|
||||
<meta name="dc.title" content="walljm.com || AJAX Bible || King James Version with Strong's Dictionary and Cross References" />
|
||||
<meta name="description" content="An AJAX implimentation of The King James Version Bible with Strong's Dictionary integrated." />
|
||||
<meta name="keywords" content="AJAX, KJV, King James Version, Strong's Dictionary, Strongs" />
|
||||
<meta name="blogchalk" content="United States, Missouri, Saint Louis, English, Jason, Male, 21-25, photography, poetry" />
|
||||
<meta name="copyright" content="All content copyrighted to Jason Wall, and available by permission of the owner." />
|
||||
<title>The Bible with Strong's Numbers and Cross References</title>
|
||||
<script type="text/javascript" src="js/jquery-1.8.2.min.js"></script>
|
||||
<script type="text/javascript" src="js/bible_ref_parsing.js"></script>
|
||||
<!--<script type="text/javascript" src="js/bible_ref_parsing.min.js"></script>-->
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function()
|
||||
{
|
||||
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:*"]
|
||||
];
|
||||
var b = $("body");
|
||||
var passed = 0;
|
||||
var failed = 0;
|
||||
|
||||
for (var i = 0; i < tests.length; i++)
|
||||
{
|
||||
|
||||
var t = tests[i];
|
||||
var ref = new Reference(t[0]);
|
||||
var r = "<b>Test " + i + ":</b> " + t[0] + "<br />";
|
||||
var parsed = ref.bookname + " " + ref.startchapter + ":" + ref.startverse + " - " + ref.endchapter + ":" + ref.endverse;
|
||||
|
||||
r += "<b>Value:</b> " + parsed + "<br />";
|
||||
if (parsed == t[1])
|
||||
{
|
||||
r += "<span style='color:green'>Passed</span><br /><br />";
|
||||
passed++;
|
||||
}
|
||||
else
|
||||
{
|
||||
r += "<b>Expected:</b> " + t[1] + "<br />";
|
||||
r += "<span style='color:red'>Failed</span><br /><br />";
|
||||
failed++;
|
||||
}
|
||||
b.append(r);
|
||||
}
|
||||
b.prepend(passed + " Passed, " + failed + " Failed<br /><br />");
|
||||
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
8
package.json
Normal file
8
package.json
Normal file
@ -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"}
|
||||
}
|
61
test/all.js
Normal file
61
test/all.js
Normal file
@ -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);
|
Loading…
x
Reference in New Issue
Block a user