Skip to content

Commit 7f3db14

Browse files
committed
Reshaping JsonLogic to return an object, now that we have more helper functions
1 parent 3a27514 commit 7f3db14

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

tests/testrunner.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ testrunner.setup({
99

1010
// specify dependency
1111
testrunner.run({
12-
deps: ["../node_modules/qunit-parameterize/qunit-parameterize.js"],
1312
code: "../logic.js",
1413
tests: "tests.js"
1514
}, function(err, report) {
15+
if(err) console.dir(err);
1616
//console.dir(report);
1717
});

tests/tests.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
var jsonLogic = require('../logic.js');
2+
13
var real_console = console.log, last_console;
24
console.log = function(logged){ last_console = logged; real_console.apply(this, arguments); };
35

4-
56
QUnit.test( "Bad operator", function( assert ) {
67
assert.throws(
7-
function(){ jsonLogic({"fubar": []}); },
8+
function(){ jsonLogic.apply({"fubar": []}); },
89
/Unrecognized operation/
910
);
1011
});
@@ -47,7 +48,7 @@ QUnit.test( "Shared JsonLogic.com tests ", function( assert ){
4748
expected = test[2];
4849

4950
assert.deepEqual(
50-
jsonLogic(rule, data),
51+
jsonLogic.apply(rule, data),
5152
expected,
5253
"jsonLogic("+ JSON.stringify(rule) +","+ JSON.stringify( data ) +") = " + expected
5354
);
@@ -58,10 +59,10 @@ QUnit.test( "Shared JsonLogic.com tests ", function( assert ){
5859
});
5960

6061
QUnit.test( "logging", function( assert ) {
61-
assert.equal( jsonLogic({"log" : [1]}), 1 );
62+
assert.equal( jsonLogic.apply({"log" : [1]}), 1 );
6263
assert.equal( last_console, 1 );
6364
});
6465

6566
QUnit.test( "edge cases", function( assert ) {
66-
assert.equal( jsonLogic(), undefined, "Called with no arguments" );
67+
assert.equal( jsonLogic.apply(), undefined, "Called with no arguments" );
6768
});

0 commit comments

Comments
 (0)