Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2150 mathias 1
if(!dojo._hasResource["dojox.wire.tests.programmatic.CompositeWire"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2
dojo._hasResource["dojox.wire.tests.programmatic.CompositeWire"] = true;
3
dojo.provide("dojox.wire.tests.programmatic.CompositeWire");
4
 
5
dojo.require("dojox.wire.CompositeWire");
6
 
7
tests.register("dojox.wire.tests.programmatic.CompositeWire", [
8
 
9
	function test_CompositeWire_children(t){
10
		var source = {a: "A", b: "B"};
11
		var target = {};
12
		var children = {x: {property: "a"}, y: {property: "b"}};
13
		var value = new dojox.wire.CompositeWire({object: source, children: children}).getValue();
14
		t.assertEqual(source.a, value.x);
15
		t.assertEqual(source.b, value.y);
16
		new dojox.wire.CompositeWire({object: target, children: children}).setValue(value);
17
		t.assertEqual(source.a, target.a);
18
		t.assertEqual(source.b, target.b);
19
 
20
		// with argument
21
		target = {};
22
		value = new dojox.wire.CompositeWire({children: children}).getValue(source);
23
		t.assertEqual(source.a, value.x);
24
		t.assertEqual(source.b, value.y);
25
		new dojox.wire.CompositeWire({children: children}).setValue(value, target);
26
		t.assertEqual(source.a, target.a);
27
		t.assertEqual(source.b, target.b);
28
 
29
		// by array
30
		target = {};
31
		children = [{property: "a"}, {property: "b"}];
32
		value = new dojox.wire.CompositeWire({object: source, children: children}).getValue();
33
		t.assertEqual(source.a, value[0]);
34
		t.assertEqual(source.b, value[1]);
35
		new dojox.wire.CompositeWire({object: target, children: children}).setValue(value);
36
		t.assertEqual(source.a, target.a);
37
		t.assertEqual(source.b, target.b);
38
 
39
		// by array with argument
40
		target = {};
41
		value = new dojox.wire.CompositeWire({children: children}).getValue(source);
42
		t.assertEqual(source.a, value[0]);
43
		t.assertEqual(source.b, value[1]);
44
		new dojox.wire.CompositeWire({children: children}).setValue(value, target);
45
		t.assertEqual(source.a, target.a);
46
		t.assertEqual(source.b, target.b);
47
	}
48
 
49
]);
50
 
51
}