Last change
on this file since 263 was
256,
checked in by hendrikvanantwerpen, 13 years ago
|
Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).
|
File size:
932 bytes
|
Line | |
---|
1 | define(["../main", "doh", "../Stateful"], function(dojo, doh){ |
---|
2 | |
---|
3 | doh.register("tests.Stateful", [ |
---|
4 | function getSetWatch(t){ |
---|
5 | var s = new dojo.Stateful({ |
---|
6 | foo: 3 |
---|
7 | }); |
---|
8 | doh.is(s.get("foo"), 3); |
---|
9 | var watching = s.watch("foo", function(name, oldValue, value){ |
---|
10 | doh.is("foo", name); |
---|
11 | doh.is(3, oldValue); |
---|
12 | doh.is(4, value); |
---|
13 | doh.is(4, s.get("foo")); |
---|
14 | }); |
---|
15 | s.set("foo", 4); |
---|
16 | doh.is(4, s.get("foo")); |
---|
17 | watching.unwatch(); |
---|
18 | s.set("foo", 5); |
---|
19 | doh.is(5, s.get("foo")); |
---|
20 | }, |
---|
21 | function setHash(t){ |
---|
22 | var s = new dojo.Stateful(); |
---|
23 | s.set({ |
---|
24 | foo:3, |
---|
25 | bar: 5 |
---|
26 | }); |
---|
27 | doh.is(3, s.get("foo")); |
---|
28 | doh.is(5, s.get("bar")); |
---|
29 | }, |
---|
30 | function wildcard(t){ |
---|
31 | var s = new dojo.Stateful(); |
---|
32 | s.set({ |
---|
33 | foo:3, |
---|
34 | bar: 5 |
---|
35 | }); |
---|
36 | var wildcard = 0; |
---|
37 | var foo = 0; |
---|
38 | s.watch(function(){ |
---|
39 | wildcard++; |
---|
40 | }); |
---|
41 | s.watch("foo", function(){ |
---|
42 | foo++; |
---|
43 | }); |
---|
44 | s.set("foo", 4); |
---|
45 | s.set("bar", 6); |
---|
46 | doh.is(2, wildcard); |
---|
47 | doh.is(1, foo); |
---|
48 | } |
---|
49 | ]); |
---|
50 | |
---|
51 | }); |
---|
Note: See
TracBrowser
for help on using the repository browser.