Skip to content

Commit 6c74dfe

Browse files
committed
Add test for serialize without any output specified (empty string as name)
1 parent cdc9de2 commit 6c74dfe

File tree

1 file changed

+37
-3
lines changed

1 file changed

+37
-3
lines changed

test.js

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -596,9 +596,8 @@ describe("ReactiveFunction", function() {
596596

597597
var firstName = ReactiveProperty("Jane");
598598
var lastName = ReactiveProperty("Smith");
599-
var fullName = ReactiveProperty();
600-
601-
ReactiveFunction({
599+
var fullName = ReactiveProperty();
600+
var rf = ReactiveFunction({
602601
inputs: [firstName, lastName],
603602
output: fullName,
604603
callback: function (first, last){
@@ -624,5 +623,40 @@ describe("ReactiveFunction", function() {
624623
assert.equal(serialized.links[1].source, "61");
625624
assert.equal(serialized.links[1].target, "59");
626625

626+
rf.destroy();
627+
});
628+
629+
it("Should serialize without any output specified (empty string as name).", function (){
630+
var a = ReactiveProperty(5);
631+
var b = ReactiveProperty(10);
632+
var sideEffect = 0;
633+
634+
var rf = ReactiveFunction({
635+
inputs: [a, b],
636+
callback: function (a, b){
637+
sideEffect++;
638+
}
639+
});
640+
641+
// For serialization.
642+
a.propertyName = "a";
643+
b.propertyName = "b";
644+
var serialized = ReactiveFunction.serializeGraph();
645+
646+
assert.equal(serialized.nodes.length, 3);
647+
assert.equal(serialized.links.length, 2);
648+
649+
//console.log(JSON.stringify(serialized, null, 2));
650+
651+
assert.equal(serialized.nodes[0].id, "62");
652+
assert.equal(serialized.nodes[1].id, "a");
653+
assert.equal(serialized.nodes[2].id, "b");
654+
655+
assert.equal(serialized.links[0].source, "a");
656+
assert.equal(serialized.links[0].target, "62");
657+
assert.equal(serialized.links[1].source, "b");
658+
assert.equal(serialized.links[1].target, "62");
659+
660+
rf.destroy();
627661
});
628662
});

0 commit comments

Comments
 (0)