Upgrade to ExtJS 4.0.1 - Released 05/18/2011
[extjs.git] / src / core / test / unit / spec / Ext-mess.backup
1 describe("Ext-mess", function() {
2    
3
4     xdescribe("Ext.repaint", function() {
5         it("should create a mask in the body", function(){
6             var body = Ext.getBody();
7
8             spyOn(Ext, "getBody").andCallThrough();
9             spyOn(body, "createChild").andCallThrough();
10
11             Ext.repaint();
12
13             expect(Ext.getBody).toHaveBeenCalled();
14             expect(body.createChild).toHaveBeenCalledWith({cls: "x-mask x-mask-transparent", tag: "div"});
15         });
16     });
17
18
19
20
21
22
23     describe("Ext.num", function() {
24         it("should work with an integer", function() {
25             expect(Ext.num(3)).toEqual(3);
26         });
27
28         it("should work with a negative integer", function() {
29             expect(Ext.num(-7)).toEqual(-7);
30         });
31
32         it("should work with a float", function() {
33             expect(Ext.num(5.43)).toEqual(5.43);
34         });
35
36         it("should work with a negative float", function() {
37             expect(Ext.num(-9.8)).toEqual(-9.8);
38         });
39
40         it("should work with Math.PI", function() {
41             expect(Ext.num(Math.PI)).toEqual(Math.PI);
42         });
43
44         it("should return undefined with null", function() {
45             expect(Ext.num(null)).toBeUndefined();
46         });
47
48         it("should work with null, with defaults", function() {
49             expect(Ext.num(null, 4)).toEqual(4);
50         });
51
52         it("should return undefined with undefined", function() {
53             expect(Ext.num(undefined)).toBeUndefined();
54         });
55
56         it("should work with undefined, with defaults", function() {
57             expect(Ext.num(undefined, 42)).toEqual(42);
58         });
59
60         it("should return undefined with boolean", function() {
61             expect(Ext.num(true)).toBeUndefined();
62         });
63
64         it("should work with boolean, with defaults", function() {
65             expect(Ext.num(true, 12)).toEqual(12);
66         });
67
68         it("should return undefined with empty string", function() {
69             expect(Ext.num("")).toBeUndefined();
70         });
71
72         it("should work with string argument in the form of a number", function() {
73             expect(Ext.num('666')).toEqual(666);
74         });
75
76         it("should return undefined with a string containing only spaces", function() {
77             expect(Ext.num("     ")).toBeUndefined();
78         });
79
80         it("should return undefined with non empty string", function() {
81             expect(Ext.num("foo")).toBeUndefined();
82         });
83
84         it("should return undefined with empty array", function() {
85             expect(Ext.num([])).toBeUndefined();
86         });
87
88         it("should return undefined with non empty array", function() {
89             expect(Ext.num([1, 2, 3])).toBeUndefined();
90         });
91
92         it("should return undefined with array with a single item", function() {
93             expect(Ext.num([3])).toBeUndefined();
94         });
95     });
96
97     describe("Ext.pluck", function() {
98         it("should return results", function() {
99             var results = Ext.pluck([{
100                 n: 11,
101                 c: 17
102             }, {
103                 n: 13,
104                 p: true
105             }, {
106                 n: 18,
107                 p: false
108             }], 'n');
109
110             expect(results).toEqual([11, 13, 18]);
111         });
112     });
113
114     describe("Ext.toArray", function() {
115         var span1,
116             span2,
117             span3,
118             span4,
119             div,
120             htmlCollection;
121
122         beforeEach(function() {
123             div = Ext.getBody().createChild({tag: "div"});
124             span1 = div.createChild({tag: "span"});
125             span2 = div.createChild({tag: "span"});
126             span3 = div.createChild({tag: "span"});
127             span4 = div.createChild({tag: "span"});
128             htmlCollection = div.dom.getElementsByTagName("span");
129         });
130
131         it("should convert iterable to an array", function() {
132            expect(Ext.toArray(htmlCollection)).toEqual([span1.dom, span2.dom, span3.dom, span4.dom]);
133         });
134
135         it("should convert a part of an iterable to an array", function() {
136            expect(Ext.toArray(htmlCollection, 1, 3)).toEqual([span2.dom, span3.dom]);
137         });
138     });
139
140
141     xdescribe("Ext.urlDecode", function() {
142         it ("should return an empty object if string is empty", function (){
143             expect(Ext.urlDecode("")).toEqual({});
144         });
145
146         it("should decode 2 keys", function(){
147             expect(Ext.urlDecode("foo=1&bar=2")).toEqual({
148                 foo: "1",
149                 bar: "2"
150             });
151         });
152
153         it("should decode 2 keys, one of them an array (overwrite off)", function() {
154             expect(Ext.urlDecode("foo=1&bar=2&bar=3&bar=4", false)).toEqual({
155                 foo: "1",
156                 bar: ['2', '3', '4']
157             });
158         });
159
160         it("should decode 2 keys, one of them an array (overwrite on)", function() {
161             expect(Ext.urlDecode("foo=1&bar=2&bar=3&bar=4", true)).toEqual({
162                 foo: "1",
163                 bar: "4"
164             });
165         });
166     });
167
168     xdescribe("Ext.urlEncode", function() {
169         it("should encode 2 keys", function() {
170             expect(Ext.urlEncode({
171                 foo: "1",
172                 bar: "2"
173             })).toEqual("foo=1&bar=2");
174         });
175
176         it("should encode 2 keys, one of them an array", function() {
177             expect(Ext.urlEncode({
178                 foo: "1",
179                 bar: ['2', '3', '4']
180             })).toEqual("foo=1&bar=2&bar=3&bar=4");
181         });
182
183         it("should encode 2 keys, one of them an array, with pre: test=1", function() {
184             expect(Ext.urlEncode({
185                 foo: "1",
186                 bar: ['2', '3', '4']
187             }, "test=1")).toEqual("test=1&foo=1&bar=2&bar=3&bar=4");
188         });
189     });
190
191
192
193
194
195
196
197
198 });