| 1 |
dojo.provide("dojox.wire.tests.programmatic.CompositeWire"); |
| 2 |
|
| 3 |
dojo.require("dojox.wire.CompositeWire"); |
| 4 |
|
| 5 |
tests.register("dojox.wire.tests.programmatic.CompositeWire", [ |
| 6 |
|
| 7 |
function test_CompositeWire_children(t){ |
| 8 |
var source = {a: "A", b: "B"}; |
| 9 |
var target = {}; |
| 10 |
var children = {x: {property: "a"}, y: {property: "b"}}; |
| 11 |
var value = new dojox.wire.CompositeWire({object: source, children: children}).getValue(); |
| 12 |
t.assertEqual(source.a, value.x); |
| 13 |
t.assertEqual(source.b, value.y); |
| 14 |
new dojox.wire.CompositeWire({object: target, children: children}).setValue(value); |
| 15 |
t.assertEqual(source.a, target.a); |
| 16 |
t.assertEqual(source.b, target.b); |
| 17 |
|
| 18 |
|
| 19 |
target = {}; |
| 20 |
value = new dojox.wire.CompositeWire({children: children}).getValue(source); |
| 21 |
t.assertEqual(source.a, value.x); |
| 22 |
t.assertEqual(source.b, value.y); |
| 23 |
new dojox.wire.CompositeWire({children: children}).setValue(value, target); |
| 24 |
t.assertEqual(source.a, target.a); |
| 25 |
t.assertEqual(source.b, target.b); |
| 26 |
|
| 27 |
|
| 28 |
target = {}; |
| 29 |
children = [{property: "a"}, {property: "b"}]; |
| 30 |
value = new dojox.wire.CompositeWire({object: source, children: children}).getValue(); |
| 31 |
t.assertEqual(source.a, value[0]); |
| 32 |
t.assertEqual(source.b, value[1]); |
| 33 |
new dojox.wire.CompositeWire({object: target, children: children}).setValue(value); |
| 34 |
t.assertEqual(source.a, target.a); |
| 35 |
t.assertEqual(source.b, target.b); |
| 36 |
|
| 37 |
|
| 38 |
target = {}; |
| 39 |
value = new dojox.wire.CompositeWire({children: children}).getValue(source); |
| 40 |
t.assertEqual(source.a, value[0]); |
| 41 |
t.assertEqual(source.b, value[1]); |
| 42 |
new dojox.wire.CompositeWire({children: children}).setValue(value, target); |
| 43 |
t.assertEqual(source.a, target.a); |
| 44 |
t.assertEqual(source.b, target.b); |
| 45 |
} |
| 46 |
|
| 47 |
]); |