aboutsummaryrefslogtreecommitdiff
path: root/includes/js/dojox/wire/tests/programmatic
diff options
context:
space:
mode:
Diffstat (limited to 'includes/js/dojox/wire/tests/programmatic')
-rw-r--r--includes/js/dojox/wire/tests/programmatic/CompositeWire.js51
-rw-r--r--includes/js/dojox/wire/tests/programmatic/ConverterDynamic.js12
-rw-r--r--includes/js/dojox/wire/tests/programmatic/DataWire.js25
-rw-r--r--includes/js/dojox/wire/tests/programmatic/TableAdapter.js24
-rw-r--r--includes/js/dojox/wire/tests/programmatic/TextAdapter.js25
-rw-r--r--includes/js/dojox/wire/tests/programmatic/TreeAdapter.js29
-rw-r--r--includes/js/dojox/wire/tests/programmatic/Wire.js123
-rw-r--r--includes/js/dojox/wire/tests/programmatic/XmlWire.js32
-rw-r--r--includes/js/dojox/wire/tests/programmatic/_base.js111
9 files changed, 0 insertions, 432 deletions
diff --git a/includes/js/dojox/wire/tests/programmatic/CompositeWire.js b/includes/js/dojox/wire/tests/programmatic/CompositeWire.js
deleted file mode 100644
index ae9866a..0000000
--- a/includes/js/dojox/wire/tests/programmatic/CompositeWire.js
+++ /dev/null
@@ -1,51 +0,0 @@
-if(!dojo._hasResource["dojox.wire.tests.programmatic.CompositeWire"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
-dojo._hasResource["dojox.wire.tests.programmatic.CompositeWire"] = true;
-dojo.provide("dojox.wire.tests.programmatic.CompositeWire");
-
-dojo.require("dojox.wire.CompositeWire");
-
-tests.register("dojox.wire.tests.programmatic.CompositeWire", [
-
- function test_CompositeWire_children(t){
- var source = {a: "A", b: "B"};
- var target = {};
- var children = {x: {property: "a"}, y: {property: "b"}};
- var value = new dojox.wire.CompositeWire({object: source, children: children}).getValue();
- t.assertEqual(source.a, value.x);
- t.assertEqual(source.b, value.y);
- new dojox.wire.CompositeWire({object: target, children: children}).setValue(value);
- t.assertEqual(source.a, target.a);
- t.assertEqual(source.b, target.b);
-
- // with argument
- target = {};
- value = new dojox.wire.CompositeWire({children: children}).getValue(source);
- t.assertEqual(source.a, value.x);
- t.assertEqual(source.b, value.y);
- new dojox.wire.CompositeWire({children: children}).setValue(value, target);
- t.assertEqual(source.a, target.a);
- t.assertEqual(source.b, target.b);
-
- // by array
- target = {};
- children = [{property: "a"}, {property: "b"}];
- value = new dojox.wire.CompositeWire({object: source, children: children}).getValue();
- t.assertEqual(source.a, value[0]);
- t.assertEqual(source.b, value[1]);
- new dojox.wire.CompositeWire({object: target, children: children}).setValue(value);
- t.assertEqual(source.a, target.a);
- t.assertEqual(source.b, target.b);
-
- // by array with argument
- target = {};
- value = new dojox.wire.CompositeWire({children: children}).getValue(source);
- t.assertEqual(source.a, value[0]);
- t.assertEqual(source.b, value[1]);
- new dojox.wire.CompositeWire({children: children}).setValue(value, target);
- t.assertEqual(source.a, target.a);
- t.assertEqual(source.b, target.b);
- }
-
-]);
-
-}
diff --git a/includes/js/dojox/wire/tests/programmatic/ConverterDynamic.js b/includes/js/dojox/wire/tests/programmatic/ConverterDynamic.js
deleted file mode 100644
index 2665148..0000000
--- a/includes/js/dojox/wire/tests/programmatic/ConverterDynamic.js
+++ /dev/null
@@ -1,12 +0,0 @@
-if(!dojo._hasResource["dojox.wire.tests.programmatic.ConverterDynamic"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
-dojo._hasResource["dojox.wire.tests.programmatic.ConverterDynamic"] = true;
-dojo.provide("dojox.wire.tests.programmatic.ConverterDynamic");
-
-dojo.declare("dojox.wire.tests.programmatic.ConverterDynamic", null, {
- convert: function(v){
- return v + 1;
- }
-});
-
-
-}
diff --git a/includes/js/dojox/wire/tests/programmatic/DataWire.js b/includes/js/dojox/wire/tests/programmatic/DataWire.js
deleted file mode 100644
index b146901..0000000
--- a/includes/js/dojox/wire/tests/programmatic/DataWire.js
+++ /dev/null
@@ -1,25 +0,0 @@
-if(!dojo._hasResource["dojox.wire.tests.programmatic.DataWire"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
-dojo._hasResource["dojox.wire.tests.programmatic.DataWire"] = true;
-dojo.provide("dojox.wire.tests.programmatic.DataWire");
-
-dojo.require("dojox.wire.DataWire");
-dojo.require("dojox.data.XmlStore");
-
-tests.register("dojox.wire.tests.programmatic.DataWire", [
-
- function test_DataWire_attribute(t){
- var store = new dojox.data.XmlStore();
- var item = store.newItem({tagName: "x"});
- new dojox.wire.DataWire({dataStore: store, object: item, attribute: "y"}).setValue("Y");
- var value = new dojox.wire.DataWire({dataStore: store, object: item, attribute: "y"}).getValue();
- t.assertEqual("Y", value);
-
- // nested attribute
- new dojox.wire.DataWire({dataStore: store, object: item, attribute: "y.z"}).setValue("Z");
- value = new dojox.wire.DataWire({dataStore: store, object: item, attribute: "y.z"}).getValue();
- t.assertEqual("Z", value);
- }
-
-]);
-
-}
diff --git a/includes/js/dojox/wire/tests/programmatic/TableAdapter.js b/includes/js/dojox/wire/tests/programmatic/TableAdapter.js
deleted file mode 100644
index 9e6adc1..0000000
--- a/includes/js/dojox/wire/tests/programmatic/TableAdapter.js
+++ /dev/null
@@ -1,24 +0,0 @@
-if(!dojo._hasResource["dojox.wire.tests.programmatic.TableAdapter"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
-dojo._hasResource["dojox.wire.tests.programmatic.TableAdapter"] = true;
-dojo.provide("dojox.wire.tests.programmatic.TableAdapter");
-
-dojo.require("dojox.wire.TableAdapter");
-
-tests.register("dojox.wire.tests.programmatic.TableAdapter", [
-
- function test_TableAdapter_columns(t){
- var source = [
- {a: "A1", b: "B1", c: "C1"},
- {a: "A2", b: "B2", c: "C2"},
- {a: "A3", b: "B3", c: "C3"}
- ];
- var columns = {x: {property: "a"}, y: {property: "b"}, z: {property: "c"}};
- var value = new dojox.wire.TableAdapter({object: source, columns: columns}).getValue();
- t.assertEqual(source[0].a, value[0].x);
- t.assertEqual(source[1].b, value[1].y);
- t.assertEqual(source[2].c, value[2].z);
- }
-
-]);
-
-}
diff --git a/includes/js/dojox/wire/tests/programmatic/TextAdapter.js b/includes/js/dojox/wire/tests/programmatic/TextAdapter.js
deleted file mode 100644
index 1014b5c..0000000
--- a/includes/js/dojox/wire/tests/programmatic/TextAdapter.js
+++ /dev/null
@@ -1,25 +0,0 @@
-if(!dojo._hasResource["dojox.wire.tests.programmatic.TextAdapter"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
-dojo._hasResource["dojox.wire.tests.programmatic.TextAdapter"] = true;
-dojo.provide("dojox.wire.tests.programmatic.TextAdapter");
-
-dojo.require("dojox.wire.TextAdapter");
-
-tests.register("dojox.wire.tests.programmatic.TextAdapter", [
-
- function test_TextAdapter_segments(t){
- var source = {a: "a", b: "b", c: "c"};
- var segments = [{property: "a"}, {property: "b"}, {property: "c"}];
- var value = new dojox.wire.TextAdapter({object: source, segments: segments}).getValue();
- t.assertEqual("abc", value);
- },
-
- function test_TextAdapter_delimiter(t){
- var source = {a: "a", b: "b", c: "c"};
- var segments = [{property: "a"}, {property: "b"}, {property: "c"}];
- var value = new dojox.wire.TextAdapter({object: source, segments: segments, delimiter: "/"}).getValue();
- t.assertEqual("a/b/c", value);
- }
-
-]);
-
-}
diff --git a/includes/js/dojox/wire/tests/programmatic/TreeAdapter.js b/includes/js/dojox/wire/tests/programmatic/TreeAdapter.js
deleted file mode 100644
index e1671ed..0000000
--- a/includes/js/dojox/wire/tests/programmatic/TreeAdapter.js
+++ /dev/null
@@ -1,29 +0,0 @@
-if(!dojo._hasResource["dojox.wire.tests.programmatic.TreeAdapter"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
-dojo._hasResource["dojox.wire.tests.programmatic.TreeAdapter"] = true;
-dojo.provide("dojox.wire.tests.programmatic.TreeAdapter");
-
-dojo.require("dojox.wire.TreeAdapter");
-
-tests.register("dojox.wire.tests.programmatic.TreeAdapter", [
-
- function test_TreeAdapter_nodes(t){
- var source = [
- {a: "A1", b: "B1", c: "C1"},
- {a: "A2", b: "B2", c: "C2"},
- {a: "A3", b: "B3", c: "C3"}
- ];
- var nodes = [
- {title: {property: "a"}, children: [
- {node: {property: "b"}},
- {title: {property: "c"}}
- ]}
- ];
- var value = new dojox.wire.TreeAdapter({object: source, nodes: nodes}).getValue();
- t.assertEqual(source[0].a, value[0].title);
- t.assertEqual(source[1].b, value[1].children[0].title);
- t.assertEqual(source[2].c, value[2].children[1].title);
- }
-
-]);
-
-}
diff --git a/includes/js/dojox/wire/tests/programmatic/Wire.js b/includes/js/dojox/wire/tests/programmatic/Wire.js
deleted file mode 100644
index 25a82ec..0000000
--- a/includes/js/dojox/wire/tests/programmatic/Wire.js
+++ /dev/null
@@ -1,123 +0,0 @@
-if(!dojo._hasResource["dojox.wire.tests.programmatic.Wire"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
-dojo._hasResource["dojox.wire.tests.programmatic.Wire"] = true;
-dojo.provide("dojox.wire.tests.programmatic.Wire");
-dojo.require("dojox.wire.Wire");
-
-//Simple connverter class to try to use.
-dojo.declare("dojox.wire.tests.programmatic.Wire.Converter", null, {
- convert: function(v){
- return v + 1;
- }
-});
-
-//Simple converter function to try to use.
-//To get it in the global namespace, gotta assign it to the
-//'window' toplevel object. Otherwise it ends up in the
-//dojo NS and can't be found.
-if (dojo.isBrowser) {
- window["__wireTestConverterFunction"] = function(v){
- return v + 1;
- };
-}else{
- var __wireTestConverterFunction = function(v){
- return v + 1;
- };
-}
-
-tests.register("dojox.wire.tests.programmatic.Wire", [
-
- function test_Wire_property(t){
- var source = {a: "A", b: {c: "B.C"}};
- var target = {a: "a", b: {c: "b.c"}};
- var value = new dojox.wire.Wire({object: source, property: "a"}).getValue();
- new dojox.wire.Wire({object: target, property: "a"}).setValue(value);
- t.assertEqual(source.a, target.a);
-
- // child property
- value = new dojox.wire.Wire({object: source, property: "b.c"}).getValue();
- new dojox.wire.Wire({object: target, property: "b.c"}).setValue(value);
- t.assertEqual(source.b.c, target.b.c);
-
- // new property
- target = {};
- value = new dojox.wire.Wire({object: source, property: "a"}).getValue();
- new dojox.wire.Wire({object: target, property: "a"}).setValue(value);
- t.assertEqual(source.a, target.a);
-
- // new parent and child property
- target.b = {};
- value = new dojox.wire.Wire({object: source, property: "b.c"}).getValue();
- new dojox.wire.Wire({object: target, property: "b.c"}).setValue(value);
- t.assertEqual(source.b.c, target.b.c);
-
- // new parent and child property
- target = {};
- value = new dojox.wire.Wire({object: source, property: "b.c"}).getValue();
- new dojox.wire.Wire({object: target, property: "b.c"}).setValue(value);
- t.assertEqual(source.b.c, target.b.c);
-
- // new array property
- source = {a: ["A"]};
- target = {};
- value = new dojox.wire.Wire({object: source, property: "a[0]"}).getValue();
- new dojox.wire.Wire({object: target, property: "a[0]"}).setValue(value);
- t.assertEqual(source.a[0], target.a[0]);
-
- // by getter/setter
- source = {getA: function() { return this._a; }, _a: "A"};
- target = {setA: function(a) { this._a = a; }};
- value = new dojox.wire.Wire({object: source, property: "a"}).getValue();
- new dojox.wire.Wire({object: target, property: "a"}).setValue(value);
- t.assertEqual(source._a, target._a);
-
- // by get/setPropertyValue
- source = {getPropertyValue: function(p) { return this["_" + p]; }, _a: "A"};
- target = {setPropertyValue: function(p, v) { this["_" + p] = v; }};
- value = new dojox.wire.Wire({object: source, property: "a"}).getValue();
- new dojox.wire.Wire({object: target, property: "a"}).setValue(value);
- t.assertEqual(source._a, target._a);
- },
-
- function test_Wire_type(t){
- var source = {a: "1"};
- var string = new dojox.wire.Wire({object: source, property: "a"}).getValue();
- t.assertEqual("11", string + 1);
- var number = new dojox.wire.Wire({object: source, property: "a", type: "number"}).getValue();
- t.assertEqual(2, number + 1);
- },
-
- function test_Wire_converterObject(t){
- var source = {a: "1"};
- var converter = {convert: function(v) { return v + 1; }};
- var string = new dojox.wire.Wire({object: source, property: "a", converter: converter}).getValue();
- t.assertEqual("11", string);
- },
-
- function test_Wire_converterFunction(t){
- var source = {a: "1"};
- var converter = {convert: function(v) { return v + 1; }};
- var number = new dojox.wire.Wire({object: source, property: "a", type: "number", converter: converter.convert}).getValue();
- t.assertEqual(2, number);
- },
-
- function test_Wire_converterObjectByString(t){
- var source = {a: "1"};
- var number = new dojox.wire.Wire({object: source, property: "a", type: "number", converter: "dojox.wire.tests.programmatic.Wire.Converter"}).getValue();
- t.assertEqual(2, number);
- },
-
- function test_Wire_converterFunctionByString(t){
- var source = {a: "1"};
- var number = new dojox.wire.Wire({object: source, property: "a", type: "number", converter: "__wireTestConverterFunction"}).getValue();
- t.assertEqual(2, number);
- },
-
- function test_Wire_converterObjectByStringDynamic(t){
- var source = {a: "1"};
- var number = new dojox.wire.Wire({object: source, property: "a", type: "number", converter: "dojox.wire.tests.programmatic.ConverterDynamic"}).getValue();
- t.assertEqual(2, number);
- }
-
-]);
-
-}
diff --git a/includes/js/dojox/wire/tests/programmatic/XmlWire.js b/includes/js/dojox/wire/tests/programmatic/XmlWire.js
deleted file mode 100644
index b0772d7..0000000
--- a/includes/js/dojox/wire/tests/programmatic/XmlWire.js
+++ /dev/null
@@ -1,32 +0,0 @@
-if(!dojo._hasResource["dojox.wire.tests.programmatic.XmlWire"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
-dojo._hasResource["dojox.wire.tests.programmatic.XmlWire"] = true;
-dojo.provide("dojox.wire.tests.programmatic.XmlWire");
-
-dojo.require("dojox.wire.XmlWire");
-
-tests.register("dojox.wire.tests.programmatic.XmlWire", [
-
- function test_XmlWire_path(t){
- var object = {};
- var wire = dojox.wire.create({object: object, property: "element"});
- new dojox.wire.XmlWire({object: wire, path: "/x/y/text()"}).setValue("Y");
- var value = new dojox.wire.XmlWire({object: object, property: "element", path: "y/text()"}).getValue();
- t.assertEqual("Y", value);
-
- // attribute
- new dojox.wire.XmlWire({object: object, property: "element", path: "y/@z"}).setValue("Z");
- value = new dojox.wire.XmlWire({object: wire, path: "/x/y/@z"}).getValue();
- t.assertEqual("Z", value);
-
- // with index
- var document = object.element.ownerDocument;
- var element = document.createElement("y");
- element.appendChild(document.createTextNode("Y2"));
- object.element.appendChild(element);
- value = new dojox.wire.XmlWire({object: object.element, path: "y[2]/text()"}).getValue();
- t.assertEqual("Y2", value);
- }
-
-]);
-
-}
diff --git a/includes/js/dojox/wire/tests/programmatic/_base.js b/includes/js/dojox/wire/tests/programmatic/_base.js
deleted file mode 100644
index 00f9abe..0000000
--- a/includes/js/dojox/wire/tests/programmatic/_base.js
+++ /dev/null
@@ -1,111 +0,0 @@
-if(!dojo._hasResource["dojox.wire.tests.programmatic._base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
-dojo._hasResource["dojox.wire.tests.programmatic._base"] = true;
-dojo.provide("dojox.wire.tests.programmatic._base");
-
-dojo.require("dojox.wire._base");
-
-tests.register("dojox.wire.tests.programmatic._base", [
-
- function test_create(t){
- var wire = dojox.wire.create({});
- t.assertTrue(wire instanceof dojox.wire.Wire);
-
- wire = dojox.wire.create({property: "a"});
- t.assertTrue(wire instanceof dojox.wire.Wire);
-
- wire = dojox.wire.create({attribute: "a"});
- t.assertTrue(wire instanceof dojox.wire.DataWire);
-
- wire = dojox.wire.create({path: "a"});
- t.assertTrue(wire instanceof dojox.wire.XmlWire);
-
- wire = dojox.wire.create({children: "a"});
- t.assertTrue(wire instanceof dojox.wire.CompositeWire);
-
- wire = dojox.wire.create({columns: "a"});
- t.assertTrue(wire instanceof dojox.wire.TableAdapter);
-
- wire = dojox.wire.create({nodes: "a"});
- t.assertTrue(wire instanceof dojox.wire.TreeAdapter);
-
- wire = dojox.wire.create({segments: "a"});
- t.assertTrue(wire instanceof dojox.wire.TextAdapter);
-
- wire = dojox.wire.create({wireClass: "dojox.wire.DataWire"});
- t.assertTrue(wire instanceof dojox.wire.DataWire);
- },
-
- function test_transfer(t){
- var source = {a: "A"};
- var target = {};
- dojox.wire.transfer(
- {object: source, property: "a"},
- {object: target, property: "a"});
- t.assertEqual(source.a, target.a);
- },
-
- function test_connect(t){
- var trigger = {transfer: function() {}, transferArgument: function() {}};
- var source = {a: "A"};
- var target = {};
- dojox.wire.connect({scope: trigger, event: "transfer"},
- {object: source, property: "a"},
- {object: target, property: "a"});
- trigger.transfer();
- t.assertEqual(source.a, target.a);
-
- // with argument
- target = {};
- dojox.wire.connect({scope: trigger, event: "transferArgument"},
- {property: "[0].a"},
- {object: target, property: "a"});
- trigger.transferArgument(source);
- t.assertEqual(source.a, target.a);
-
- // by topic
- target = {};
- dojox.wire.connect({topic: "transfer"},
- {object: source, property: "a"},
- {object: target, property: "a"});
- dojo.publish("transfer");
- t.assertEqual(source.a, target.a);
-
- // by topic with argument
- target = {};
- dojox.wire.connect({topic: "transferArgument"},
- {property: "[0].a"},
- {object: target, property: "a"});
- dojo.publish("transferArgument", [source]);
- t.assertEqual(source.a, target.a);
- },
-
- function test_disconnect(t){
- var trigger = {transferDisconnect: function() {}};
- var source = {a: "A"};
- var target = {};
- var connection = dojox.wire.connect({scope: trigger, event: "transferDisconnect"},
- {object: source, property: "a"},
- {object: target, property: "a"});
- trigger.transferDisconnect();
- t.assertEqual(source.a, target.a);
- delete target.a;
- dojox.wire.disconnect(connection);
- trigger.transferDisconnect();
- t.assertEqual(undefined, target.a);
-
- // by topic
- target = {};
- connection = dojox.wire.connect({topic: "transferDisconnect"},
- {object: source, property: "a"},
- {object: target, property: "a"});
- dojo.publish("transferDisconnect");
- t.assertEqual(source.a, target.a);
- delete target.a;
- dojox.wire.disconnect(connection);
- dojo.publish("transferDisconnect");
- t.assertEqual(undefined, target.a);
- }
-
-]);
-
-}