reactive-function
Advanced tools
Comparing version 0.13.0 to 0.13.1
@@ -47,2 +47,6 @@ var ReactiveProperty = require("reactive-property"); | ||
var output = options.output; | ||
if(!defined(inputs)){ | ||
throw new Error("Attempting to use an undefined property as a reactive function input."); | ||
} | ||
@@ -49,0 +53,0 @@ if(!output){ |
{ | ||
"name": "reactive-function", | ||
"version": "0.13.0", | ||
"version": "0.13.1", | ||
"description": "A library for managing data flows and changing state.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
64
test.js
@@ -464,2 +464,47 @@ // Unit tests for reactive-function. | ||
it("Should execute a doubly nested digest.", function (){ | ||
var a = ReactiveProperty(5); | ||
var b = ReactiveProperty(); | ||
var c = ReactiveProperty(); | ||
var d = ReactiveProperty(); | ||
var e = ReactiveProperty(); | ||
var rf1 = ReactiveFunction({ | ||
inputs: [a], | ||
callback: function (a){ | ||
for(var i = 0; i < a; i++){ | ||
b(i); | ||
ReactiveFunction.digest(); | ||
assert.equal(c(), i / 2); | ||
} | ||
} | ||
}); | ||
var rf2 = ReactiveFunction({ | ||
inputs: [b], | ||
output: c, | ||
callback: function (b){ | ||
d(b); | ||
ReactiveFunction.digest(); | ||
return e(); | ||
} | ||
}); | ||
var rf3 = ReactiveFunction({ | ||
inputs: [d], | ||
output: e, | ||
callback: function (d){ | ||
return d / 2; | ||
} | ||
}); | ||
ReactiveFunction.digest(); | ||
rf1.destroy(); | ||
rf2.destroy(); | ||
rf3.destroy(); | ||
}); | ||
}); | ||
@@ -571,3 +616,3 @@ | ||
// Fix by changing the value of initialId. | ||
var initialId = 60; | ||
var initialId = 66; | ||
@@ -692,2 +737,19 @@ it("Should serialize the data flow graph.", function (){ | ||
}); | ||
describe("Edge Cases and Error Handling", function (){ | ||
it("Should throw error when input property is not defined.", function(){ | ||
var b = ReactiveProperty(); | ||
assert.throws(function (){ | ||
var rf = ReactiveFunction({ | ||
inputs: [undefined], | ||
output: b, | ||
callback: function (a){ | ||
return a * 2; | ||
} | ||
}); | ||
}, /Attempting to use an undefined property as a reactive function input/); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40926
753