| 1 | <html> |
| 2 | <head> |
| 3 | <title>Test Action</title> |
| 4 | <script type="text/javascript" src="../../../../dojo/dojo.js" data-dojo-config="isDebug: true, parseOnLoad: true"></script> |
| 5 | <script type="text/javascript"> |
| 6 | dojo.provide("dojox.wire.ml.tests.markup.Action"); |
| 7 | |
| 8 | dojo.require("dojo.parser"); |
| 9 | dojo.require("doh.runner"); |
| 10 | dojo.require("dojox.wire.ml.Action"); |
| 11 | dojo.require("dojox.wire.ml.Transfer"); |
| 12 | |
| 13 | dojox.wire.ml.tests.markup.Action = { |
| 14 | transfer: function(){}, |
| 15 | source: {a: "A", b: "B"} |
| 16 | }; |
| 17 | |
| 18 | dojo.addOnLoad(function(){ |
| 19 | doh.register("dojox.wire.ml.tests.markup.Action", [ |
| 20 | function test_Action_triggerEvent(t){ |
| 21 | dojox.wire.ml.tests.markup.Action.target = {}; |
| 22 | dojox.wire.ml.tests.markup.Action.transfer(); |
| 23 | t.assertEqual(dojox.wire.ml.tests.markup.Action.source.a, dojox.wire.ml.tests.markup.Action.target.a); |
| 24 | t.assertEqual(dojox.wire.ml.tests.markup.Action.source.b, dojox.wire.ml.tests.markup.Action.target.b); |
| 25 | }, |
| 26 | |
| 27 | function test_Action_triggerTopic(t){ |
| 28 | dojox.wire.ml.tests.markup.Action.target = {}; |
| 29 | dojo.publish("transfer"); |
| 30 | t.assertEqual(dojox.wire.ml.tests.markup.Action.source.a, dojox.wire.ml.tests.markup.Action.target.a); |
| 31 | }, |
| 32 | |
| 33 | function test_ActionFilter_required(t){ |
| 34 | dojox.wire.ml.tests.markup.Action.target = {}; |
| 35 | dojo.publish("transferFilter"); |
| 36 | t.assertEqual(undefined, dojox.wire.ml.tests.markup.Action.target.a); |
| 37 | t.assertEqual("no required", dojox.wire.ml.tests.markup.Action.error); |
| 38 | dojox.wire.ml.tests.markup.Action.required = true; |
| 39 | dojo.publish("transferFilter"); |
| 40 | t.assertEqual(dojox.wire.ml.tests.markup.Action.source.a, dojox.wire.ml.tests.markup.Action.target.a); |
| 41 | }, |
| 42 | |
| 43 | function test_ActionFilter_requiredSpecificNumber(t){ |
| 44 | dojox.wire.ml.tests.markup.Action.value = null |
| 45 | dojox.wire.ml.tests.markup.Action.target = {}; |
| 46 | dojo.publish("transferFilterNumber"); |
| 47 | |
| 48 | t.assertEqual(undefined, dojox.wire.ml.tests.markup.Action.target.a); |
| 49 | |
| 50 | dojox.wire.ml.tests.markup.Action.value = 20; |
| 51 | dojo.publish("transferFilterNumber"); |
| 52 | t.assertEqual(dojox.wire.ml.tests.markup.Action.source.a, dojox.wire.ml.tests.markup.Action.target.a); |
| 53 | }, |
| 54 | |
| 55 | function test_ActionFilter_requiredSpecificBoolean(t){ |
| 56 | dojox.wire.ml.tests.markup.Action.value = null; |
| 57 | dojox.wire.ml.tests.markup.Action.target = {}; |
| 58 | dojo.publish("transferFilterBoolean"); |
| 59 | |
| 60 | t.assertEqual(undefined, dojox.wire.ml.tests.markup.Action.target.a); |
| 61 | |
| 62 | dojox.wire.ml.tests.markup.Action.value = true; |
| 63 | dojo.publish("transferFilterBoolean"); |
| 64 | t.assertEqual(dojox.wire.ml.tests.markup.Action.source.a, dojox.wire.ml.tests.markup.Action.target.a); |
| 65 | }, |
| 66 | |
| 67 | function test_ActionFilter_requiredSpecificString(t){ |
| 68 | dojox.wire.ml.tests.markup.Action.target = {}; |
| 69 | dojox.wire.ml.tests.markup.Action.value = null; |
| 70 | dojo.publish("transferFilterString"); |
| 71 | |
| 72 | t.assertEqual(undefined, dojox.wire.ml.tests.markup.Action.target.a); |
| 73 | |
| 74 | dojox.wire.ml.tests.markup.Action.value = "executeThis"; |
| 75 | dojo.publish("transferFilterString"); |
| 76 | t.assertEqual(dojox.wire.ml.tests.markup.Action.source.a, dojox.wire.ml.tests.markup.Action.target.a); |
| 77 | } |
| 78 | ]); |
| 79 | doh.run(); |
| 80 | }); |
| 81 | </script> |
| 82 | </head> |
| 83 | <body> |
| 84 | <div dojoType="dojox.wire.ml.Action" |
| 85 | trigger="dojox.wire.ml.tests.markup.Action" |
| 86 | triggerEvent="transfer"> |
| 87 | <div dojoType="dojox.wire.ml.Transfer" |
| 88 | source="dojox.wire.ml.tests.markup.Action.source.a" |
| 89 | target="dojox.wire.ml.tests.markup.Action.target.a"></div> |
| 90 | <div dojoType="dojox.wire.ml.Transfer" |
| 91 | source="dojox.wire.ml.tests.markup.Action.source.b" |
| 92 | target="dojox.wire.ml.tests.markup.Action.target.b"></div> |
| 93 | </div> |
| 94 | <div dojoType="dojox.wire.ml.Action" |
| 95 | triggerTopic="transfer"> |
| 96 | <div dojoType="dojox.wire.ml.Transfer" |
| 97 | source="dojox.wire.ml.tests.markup.Action.source.a" |
| 98 | target="dojox.wire.ml.tests.markup.Action.target.a"></div> |
| 99 | </div> |
| 100 | <div dojoType="dojox.wire.ml.Action" |
| 101 | triggerTopic="transferFilter"> |
| 102 | <div dojoType="dojox.wire.ml.ActionFilter" |
| 103 | required="dojox.wire.ml.tests.markup.Action.required" |
| 104 | message="no required" |
| 105 | error="dojox.wire.ml.tests.markup.Action.error"></div> |
| 106 | <div dojoType="dojox.wire.ml.Transfer" |
| 107 | source="dojox.wire.ml.tests.markup.Action.source.a" |
| 108 | target="dojox.wire.ml.tests.markup.Action.target.a"></div> |
| 109 | </div> |
| 110 | |
| 111 | <div dojoType="dojox.wire.ml.Action" |
| 112 | triggerTopic="transferFilterNumber"> |
| 113 | <div dojoType="dojox.wire.ml.ActionFilter" |
| 114 | required="dojox.wire.ml.tests.markup.Action.value" |
| 115 | requiredValue="20" |
| 116 | type="number"> |
| 117 | </div> |
| 118 | <div dojoType="dojox.wire.ml.Transfer" |
| 119 | source="dojox.wire.ml.tests.markup.Action.source.a" |
| 120 | target="dojox.wire.ml.tests.markup.Action.target.a"></div> |
| 121 | </div> |
| 122 | |
| 123 | <div dojoType="dojox.wire.ml.Action" |
| 124 | triggerTopic="transferFilterBoolean"> |
| 125 | <div dojoType="dojox.wire.ml.ActionFilter" |
| 126 | required="dojox.wire.ml.tests.markup.Action.value" |
| 127 | requiredValue="true" |
| 128 | type="boolean"> |
| 129 | </div> |
| 130 | <div dojoType="dojox.wire.ml.Transfer" |
| 131 | source="dojox.wire.ml.tests.markup.Action.source.a" |
| 132 | target="dojox.wire.ml.tests.markup.Action.target.a"></div> |
| 133 | </div> |
| 134 | |
| 135 | <div dojoType="dojox.wire.ml.Action" |
| 136 | triggerTopic="transferFilterString"> |
| 137 | <div dojoType="dojox.wire.ml.ActionFilter" |
| 138 | required="dojox.wire.ml.tests.markup.Action.value" |
| 139 | requiredValue="executeThis"> |
| 140 | </div> |
| 141 | <div dojoType="dojox.wire.ml.Transfer" |
| 142 | source="dojox.wire.ml.tests.markup.Action.source.a" |
| 143 | target="dojox.wire.ml.tests.markup.Action.target.a"></div> |
| 144 | </div> |
| 145 | |
| 146 | </body> |
| 147 | </html> |