source: Dev/branches/rest-dojo-ui/client/dojo/tests/AdapterRegistry.js @ 263

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: 1.5 KB
Line 
1define(["../main", "doh", "../AdapterRegistry"], function(dojo, doh){
2
3doh.register("tests.AdapterRegistry",
4        [
5                function ctor(t){
6                        var taa = new dojo.AdapterRegistry();
7                        t.is(0, taa.pairs.length);
8                        t.f(taa.returnWrappers);
9
10                        var taa = new dojo.AdapterRegistry(true);
11                        t.t(taa.returnWrappers);
12                },
13
14                function register(t){
15                        var taa = new dojo.AdapterRegistry();
16                        taa.register("blah",
17                                function(str){ return str == "blah"; },
18                                function(){ return "blah"; }
19                        );
20                        t.is(1, taa.pairs.length);
21                        t.is("blah", taa.pairs[0][0]);
22
23                        taa.register("thinger");
24                        taa.register("prepend", null, null, true, true);
25                        t.is("prepend", taa.pairs[0][0]);
26                        t.t(taa.pairs[0][3]);
27                },
28
29                /*
30                function match(t){
31                },
32                */
33
34                function noMatch(t){
35                        var taa = new dojo.AdapterRegistry();
36                        var threw = false;
37                        try{
38                                taa.match("blah");
39                        }catch(e){
40                                threw = true;
41                        }
42                        t.t(threw);
43                },
44
45                function returnWrappers(t){
46                        var taa = new dojo.AdapterRegistry();
47                        taa.register("blah",
48                                function(str){ return str == "blah"; },
49                                function(){ return "blah"; }
50                        );
51                        t.is("blah", taa.match("blah"));
52
53                        taa.returnWrappers = true;
54                        t.is("blah", taa.match("blah")());
55                },
56
57                function unregister(t){
58                        var taa = new dojo.AdapterRegistry();
59                        taa.register("blah",
60                                function(str){ return str == "blah"; },
61                                function(){ return "blah"; }
62                        );
63                        taa.register("thinger");
64                        taa.register("prepend", null, null, true, true);
65                        taa.unregister("prepend");
66                        t.is(2, taa.pairs.length);
67                        t.is("blah", taa.pairs[0][0]);
68                }
69        ]
70);
71
72});
Note: See TracBrowser for help on using the repository browser.