Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / src / core / test / unit / spec / Ext.js
1 describe("Ext", function() {
2
3     describe("Ext.apply", function() {
4         var origin, o;
5
6         beforeEach(function() {
7             origin = {
8                 name: 'value',
9                 something: 'cool',
10                 items: [1,2,3],
11                 method: function() {
12                     this.myMethodCalled = true;
13                 },
14                 toString: function() {
15                     this.myToStringCalled = true;
16                 }
17             };
18         });
19
20         it("should copy normal properties", function() {
21             Ext.apply(origin, {
22                 name: 'newName',
23                 items: [4,5,6],
24                 otherThing: 'not cool',
25                 isCool: false
26             });
27
28             expect(origin.name).toEqual('newName');
29             expect(origin.items).toEqual([4,5,6]);
30             expect(origin.something).toEqual('cool');
31             expect(origin.otherThing).toEqual('not cool');
32             expect(origin.isCool).toEqual(false);
33         });
34
35         it("should copy functions", function() {
36             Ext.apply(origin, {
37                 method: function() {
38                     this.newMethodCalled = true;
39                 }
40             });
41
42             origin.method();
43
44             expect(origin.myMethodCalled).not.toBeDefined();
45             expect(origin.newMethodCalled).toBeTruthy();
46         });
47
48         it("should copy non-enumerables", function() {
49             Ext.apply(origin, {
50                 toString: function() {
51                     this.newToStringCalled = true;
52                 }
53             });
54
55             origin.toString();
56
57             expect(origin.myToStringCalled).not.toBeDefined();
58             expect(origin.newToStringCalled).toBeTruthy();
59         });
60
61         it("should apply properties and return an object", function() {
62             o = Ext.apply({}, {
63                 foo: 1,
64                 bar: 2
65             });
66
67             expect(o).toEqual({
68                 foo: 1,
69                 bar: 2
70             });
71         });
72
73         it("should change the reference of the object", function() {
74             o = {};
75             Ext.apply(o, {
76                 opt1: 'x',
77                 opt2: 'y'
78             });
79
80             expect(o).toEqual({
81                 opt1: 'x',
82                 opt2: 'y'
83             });
84         });
85
86         it("should overwrite properties", function() {
87             o = Ext.apply({
88                 foo: 1,
89                 baz: 4
90             }, {
91                 foo: 2,
92                 bar: 3
93             });
94
95             expect(o).toEqual({
96                 foo: 2,
97                 bar: 3,
98                 baz: 4
99             });
100         });
101
102         it("should use default", function() {
103             o = {};
104
105             Ext.apply(o, {
106                 foo: 'new',
107                 exist: true
108             }, {
109                 foo: 'old',
110                 def: true
111             });
112
113             expect(o).toEqual({
114                 foo: 'new',
115                 def: true,
116                 exist: true
117             });
118         });
119
120         it("should override all defaults", function() {
121             o = Ext.apply({}, {
122                 foo: 'foo',
123                 bar: 'bar'
124             }, {
125                 foo: 'oldFoo',
126                 bar: 'oldBar'
127             });
128
129             expect(o).toEqual( {
130                 foo: 'foo',
131                 bar: 'bar'
132             });
133         });
134
135         it("should return null if null is passed as first argument", function() {
136            expect(Ext.apply(null, {})).toBeNull();
137         });
138
139         it("should return the object if second argument is no defined", function() {
140             o = {
141                 foo: 1
142             };
143             expect(Ext.apply(o)).toEqual(o);
144         });
145
146         it("should override valueOf", function() {
147             o = Ext.apply({}, {valueOf: 1});
148
149             expect(o.valueOf).toEqual(1);
150         });
151
152         it("should override toString", function() {
153             o = Ext.apply({}, {toString: 3});
154
155             expect(o.toString).toEqual(3);
156
157         });
158     });
159
160     describe("Ext.applyIf", function(){
161         var o;
162
163         it("should apply properties and return an object with an empty destination object", function() {
164             o = Ext.applyIf({}, {
165                 foo: 'foo',
166                 bar: 'bar'
167             });
168
169             expect(o).toEqual( {
170                 foo: 'foo',
171                 bar: 'bar'
172             });
173         });
174
175         it("should not override default properties", function() {
176             o = Ext.applyIf({
177                 foo: 'foo'
178             }, {
179                 foo: 'oldFoo'
180             });
181
182             expect(o).toEqual({
183                 foo: 'foo'
184             });
185         });
186
187         it("should not override default properties with mixing properties", function() {
188             o = Ext.applyIf({
189                 foo: 1,
190                 bar: 2
191             }, {
192                 bar: 3,
193                 baz: 4
194             });
195
196             expect(o).toEqual({
197                 foo: 1,
198                 bar: 2,
199                 baz: 4
200             });
201         });
202
203           it("should change the reference of the object", function() {
204             o = {};
205             Ext.applyIf(o, {
206                 foo: 2
207             }, {
208                 foo: 1
209             });
210
211             expect(o).toEqual({
212                 foo: 2
213             });
214         });
215
216         it("should return null if null is passed as first argument", function() {
217            expect(Ext.applyIf(null, {})).toBeNull();
218         });
219
220         it("should return the object if second argument is no defined", function() {
221             o = {
222                 foo: 1
223             };
224
225             expect(Ext.applyIf(o)).toEqual(o);
226         });
227     });
228
229
230     describe("Ext.extend", function() {
231         var Dude, Awesome, david;
232
233         beforeEach(function() {
234             Dude = Ext.extend(Object, {
235                 constructor: function(config){
236                     Ext.apply(this, config);
237                     this.isBadass = false;
238                 }
239             });
240
241             Awesome = Ext.extend(Dude, {
242                 constructor: function(){
243                     Awesome.superclass.constructor.apply(this, arguments);
244                     this.isBadass = true;
245                 }
246             });
247
248             david = new Awesome({
249                 davis: 'isAwesome'
250             });
251         });
252
253         it("should throw an error if superclass isn't defined", function() {
254             expect(function() {
255                 Ext.extend(undefined, {});
256             }).toRaiseExtError("Attempting to extend from a class which has not been loaded on the page.");
257         });
258
259         it("should create a superclass that return the original classe", function() {
260             expect(david.superclass).toEqual(Dude.prototype);
261         });
262
263         it("should add override method", function() {
264             expect(typeof david.override === 'function').toBe(true);
265         });
266
267         it("should override redefined methods", function() {
268             expect(david.isBadass).toBe(true);
269         });
270
271         it("should keep new properties", function() {
272             expect(david.davis).toEqual('isAwesome');
273         });
274     });
275
276     describe("Ext.override", function(){
277         var Dude,
278             extApplySpy;
279
280         beforeEach(function(){
281             Dude = function(){}; // avoid to directly override Object class
282             extApplySpy = spyOn(Ext, "apply");
283         });
284
285         it("should apply override", function(){
286             var override = {foo: true};
287
288             Ext.override(Dude, override);
289
290             expect(extApplySpy).toHaveBeenCalledWith(Dude.prototype, override);
291         });
292     });
293
294     describe("Ext.typeOf", function() {
295         it("should return null", function() {
296             expect(Ext.typeOf(null)).toEqual('null');
297         });
298         it("should return undefined", function() {
299             expect(Ext.typeOf(undefined)).toEqual('undefined');
300         });
301         it("should return undefined", function() {
302             expect(Ext.typeOf(window.someWeirdPropertyThatDoesntExist)).toEqual('undefined');
303         });
304         it("should return string", function() {
305             expect(Ext.typeOf('')).toEqual('string');
306         });
307         it("should return string", function() {
308             expect(Ext.typeOf('something')).toEqual('string');
309         });
310         it("should return string", function() {
311             expect(Ext.typeOf('1.2')).toEqual('string');
312         });
313         it("should return number", function() {
314             expect(Ext.typeOf(1)).toEqual('number');
315         });
316         it("should return number", function() {
317             expect(Ext.typeOf(1.2)).toEqual('number');
318         });
319         it("should return boolean", function() {
320             expect(Ext.typeOf(true)).toEqual('boolean');
321         });
322         it("should return boolean", function() {
323             expect(Ext.typeOf(false)).toEqual('boolean');
324         });
325         it("should return array", function() {
326             expect(Ext.typeOf([1,2,3])).toEqual('array');
327         });
328         it("should return array", function() {
329             expect(Ext.typeOf(new Array(1,2,3))).toEqual('array');
330         });
331         it("should return function 1", function() {
332             expect(Ext.typeOf(function(){})).toEqual('function');
333         });
334         // Don't run this test in IE
335         if (typeof alert === 'function') {
336             it("should return function 2", function() {
337                 expect(Ext.typeOf(prompt)).toEqual('function');
338             });
339         }
340         it("should return function 3", function() {
341             expect(Ext.typeOf(new Function())).toEqual('function');
342         });
343         it("should return regexp 1", function() {
344             expect(Ext.typeOf(/test/)).toEqual('regexp');
345         });
346         it("should return regexp 2", function() {
347             expect(Ext.typeOf(new RegExp('test'))).toEqual('regexp');
348         });
349         it("should return date", function() {
350             expect(Ext.typeOf(new Date())).toEqual('date');
351         });
352         it("should return textnode", function() {
353             expect(Ext.typeOf(document.createTextNode('tada'))).toEqual('textnode');
354         });
355         it("should return whitespace", function() {
356             expect(Ext.typeOf(document.createTextNode(' '))).toEqual('whitespace');
357         });
358         it("should return whitespace", function() {
359             expect(Ext.typeOf(document.createTextNode('         '))).toEqual('whitespace');
360         });
361         it("should return element", function() {
362             expect(Ext.typeOf(document.getElementsByTagName('body')[0])).toEqual('element');
363         });
364         it("should return element", function() {
365             expect(Ext.typeOf(document.createElement('button'))).toEqual('element');
366         });
367         it("should return element", function() {
368             expect(Ext.typeOf(new Image())).toEqual('element');
369         });
370         it("should return object 1", function() {
371             expect(Ext.typeOf({some: 'stuff'})).toEqual('object');
372         });
373         it("should return object 2", function() {
374             expect(Ext.typeOf(new Object())).toEqual('object');
375         });
376         it("should return object 3", function() {
377             expect(Ext.typeOf(window)).toEqual('object');
378         });
379         it("should return boolean", function() {
380             expect(Ext.typeOf(new Boolean(true))).toEqual('boolean');
381         });
382         it("should return number", function() {
383             expect(Ext.typeOf(new Number(1.2))).toEqual('number');
384         });
385     });
386
387     describe("Ext.isIterable", function() {
388         it("should return true with empty array", function() {
389             expect(Ext.isIterable([])).toBe(true);
390         });
391
392         it("should return true with filled array", function() {
393             expect(Ext.isIterable([1, 2, 3, 4])).toBe(true);
394         });
395
396         it("should return false with boolean true", function() {
397             expect(Ext.isIterable(true)).toBe(false);
398         });
399
400         it("should return false with boolean false", function() {
401             expect(Ext.isIterable(false)).toBe(false);
402         });
403
404         it("should return false with string", function() {
405             expect(Ext.isIterable("foo")).toBe(false);
406         });
407
408         it("should return false with empty string", function() {
409             expect(Ext.isIterable("")).toBe(false);
410         });
411
412         it("should return false with number", function() {
413             expect(Ext.isIterable(1)).toBe(false);
414         });
415
416         it("should return false with null", function() {
417             expect(Ext.isIterable(null)).toBe(false);
418         });
419
420         it("should return false with undefined", function() {
421             expect(Ext.isIterable(undefined)).toBe(false);
422         });
423
424         it("should return false with date", function() {
425             expect(Ext.isIterable(new Date())).toBe(false);
426         });
427
428         it("should return false with empty object", function() {
429             expect(Ext.isIterable({})).toBe(false);
430         });
431
432         it("should return true with node list", function() {
433             expect(Ext.isIterable(document.getElementsByTagName('body'))).toBe(true);
434         });
435
436         it("should return true with html collection", function() {
437             expect(Ext.isIterable(document.images)).toBe(true);
438         });
439     });
440
441     describe("Ext.isArray", function() {
442         it("should return true with empty array", function() {
443             expect(Ext.isArray([])).toBe(true);
444         });
445
446         it("should return true with filled array", function() {
447             expect(Ext.isArray([1, 2, 3, 4])).toBe(true);
448         });
449
450         it("should return false with boolean true", function() {
451             expect(Ext.isArray(true)).toBe(false);
452         });
453
454         it("should return false with boolean false", function() {
455             expect(Ext.isArray(false)).toBe(false);
456         });
457
458         it("should return false with string", function() {
459             expect(Ext.isArray("foo")).toBe(false);
460         });
461
462         it("should return false with empty string", function() {
463             expect(Ext.isArray("")).toBe(false);
464         });
465
466         it("should return false with number", function() {
467             expect(Ext.isArray(1)).toBe(false);
468         });
469
470         it("should return false with null", function() {
471             expect(Ext.isArray(null)).toBe(false);
472         });
473
474         it("should return false with undefined", function() {
475             expect(Ext.isArray(undefined)).toBe(false);
476         });
477
478         it("should return false with date", function() {
479             expect(Ext.isArray(new Date())).toBe(false);
480         });
481
482         it("should return false with empty object", function() {
483             expect(Ext.isArray({})).toBe(false);
484         });
485
486         it("should return false with node list", function() {
487             expect(Ext.isArray(document.getElementsByTagName('body'))).toBe(false);
488         });
489
490         it("should return false with custom class that has a length property", function() {
491             var C = Ext.extend(Object, {
492                 length: 1
493             });
494             expect(Ext.isArray(new C())).toBe(false);
495         });
496
497         //it("should return false with element", function() {
498         //    expect(Ext.isElement(Ext.getBody().dom)).toBe(false);
499         //});
500     });
501
502     describe("Ext.isBoolean", function() {
503         it("should return false with empty array", function() {
504             expect(Ext.isBoolean([])).toBe(false);
505         });
506
507         it("should return false with filled array", function() {
508             expect(Ext.isBoolean([1, 2, 3, 4])).toBe(false);
509         });
510
511         it("should return true with boolean true", function() {
512             expect(Ext.isBoolean(true)).toBe(true);
513         });
514
515         it("should return true with boolean false", function() {
516             expect(Ext.isBoolean(false)).toBe(true);
517         });
518
519         it("should return false with string", function() {
520             expect(Ext.isBoolean("foo")).toBe(false);
521         });
522
523         it("should return false with empty string", function() {
524             expect(Ext.isBoolean("")).toBe(false);
525         });
526
527         it("should return false with number", function() {
528             expect(Ext.isBoolean(1)).toBe(false);
529         });
530
531         it("should return false with null", function() {
532             expect(Ext.isBoolean(null)).toBe(false);
533         });
534
535         it("should return false with undefined", function() {
536             expect(Ext.isBoolean(undefined)).toBe(false);
537         });
538
539         it("should return false with date", function() {
540             expect(Ext.isBoolean(new Date())).toBe(false);
541         });
542
543         it("should return false with empty object", function() {
544             expect(Ext.isBoolean({})).toBe(false);
545         });
546
547         it("should return false with node list", function() {
548             expect(Ext.isBoolean(document.getElementsByTagName('body'))).toBe(false);
549         });
550
551         //it("should return false with element", function() {
552         //    expect(Ext.isElement(Ext.getBody().dom)).toBe(false);
553         //});
554     });
555
556     describe("Ext.isDate", function() {
557         it("should return false with empty array", function() {
558             expect(Ext.isDate([])).toBe(false);
559         });
560
561         it("should return false with filled array", function() {
562             expect(Ext.isDate([1, 2, 3, 4])).toBe(false);
563         });
564
565         it("should return false with boolean true", function() {
566             expect(Ext.isDate(true)).toBe(false);
567         });
568
569         it("should return false with boolean false", function() {
570             expect(Ext.isDate(false)).toBe(false);
571         });
572
573         it("should return false with string", function() {
574             expect(Ext.isDate("foo")).toBe(false);
575         });
576
577         it("should return false with empty string", function() {
578             expect(Ext.isDate("")).toBe(false);
579         });
580
581         it("should return false with number", function() {
582             expect(Ext.isDate(1)).toBe(false);
583         });
584
585         it("should return false with null", function() {
586             expect(Ext.isDate(null)).toBe(false);
587         });
588
589         it("should return false with undefined", function() {
590             expect(Ext.isDate(undefined)).toBe(false);
591         });
592
593         it("should return true with date", function() {
594             expect(Ext.isDate(new Date())).toBe(true);
595         });
596
597         it("should return false with empty object", function() {
598             expect(Ext.isDate({})).toBe(false);
599         });
600
601         it("should return false with node list", function() {
602             expect(Ext.isDate(document.getElementsByTagName('body'))).toBe(false);
603         });
604
605         it("should return false with element", function() {
606             expect(Ext.isDate(Ext.getBody().dom)).toBe(false);
607         });
608     });
609
610     describe("Ext.isDefined", function() {
611         it("should return true with empty array", function() {
612             expect(Ext.isDefined([])).toBe(true);
613         });
614
615         it("should return true with filled array", function() {
616             expect(Ext.isDefined([1, 2, 3, 4])).toBe(true);
617         });
618
619         it("should return true with boolean true", function() {
620             expect(Ext.isDefined(true)).toBe(true);
621         });
622
623         it("should return true with boolean false", function() {
624             expect(Ext.isDefined(false)).toBe(true);
625         });
626
627         it("should return true with string", function() {
628             expect(Ext.isDefined("foo")).toBe(true);
629         });
630
631         it("should return true with empty string", function() {
632             expect(Ext.isDefined("")).toBe(true);
633         });
634
635         it("should return true with number", function() {
636             expect(Ext.isDefined(1)).toBe(true);
637         });
638
639         it("should return true with null", function() {
640             expect(Ext.isDefined(null)).toBe(true);
641         });
642
643         it("should return false with undefined", function() {
644             expect(Ext.isDefined(undefined)).toBe(false);
645         });
646
647         it("should return true with date", function() {
648             expect(Ext.isDefined(new Date())).toBe(true);
649         });
650
651         it("should return true with empty object", function() {
652             expect(Ext.isDefined({})).toBe(true);
653         });
654
655         it("should return true with node list", function() {
656             expect(Ext.isDefined(document.getElementsByTagName('body'))).toBe(true);
657         });
658
659         //it("should return true with element", function() {
660         //    expect(Ext.isElement(Ext.getBody().dom)).toBe(true);
661         //});
662     });
663
664     describe("Ext.isElement", function() {
665         it("should return false with empty array", function() {
666             expect(Ext.isElement([])).toBe(false);
667         });
668
669         it("should return false with filled array", function() {
670             expect(Ext.isElement([1, 2, 3, 4])).toBe(false);
671         });
672
673         it("should return false with boolean true", function() {
674             expect(Ext.isElement(true)).toBe(false);
675         });
676
677         it("should return false with boolean false", function() {
678             expect(Ext.isElement(false)).toBe(false);
679         });
680
681         it("should return false with string", function() {
682             expect(Ext.isElement("foo")).toBe(false);
683         });
684
685         it("should return false with empty string", function() {
686             expect(Ext.isElement("")).toBe(false);
687         });
688
689         it("should return false with number", function() {
690             expect(Ext.isElement(1)).toBe(false);
691         });
692
693         it("should return false with null", function() {
694             expect(Ext.isElement(null)).toBe(false);
695         });
696
697         it("should return false with undefined", function() {
698             expect(Ext.isElement(undefined)).toBe(false);
699         });
700
701         it("should return false with date", function() {
702             expect(Ext.isElement(new Date())).toBe(false);
703         });
704
705         it("should return false with empty object", function() {
706             expect(Ext.isElement({})).toBe(false);
707         });
708
709         it("should return false with node list", function() {
710             expect(Ext.isElement(document.getElementsByTagName('body'))).toBe(false);
711         });
712
713         //it("should return true with element", function() {
714         //    expect(Ext.isElement(Ext.getBody().dom)).toBe(true);
715         //});
716
717         //it("should return false with Ext.core.Element", function() {
718         //    expect(Ext.isElement(Ext.getBody().dom)).toBe(true);
719         //});
720     });
721
722     describe("Ext.isEmpty", function() {
723         it("should return true with empty array", function() {
724             expect(Ext.isEmpty([])).toBe(true);
725         });
726
727         it("should return false with filled array", function() {
728             expect(Ext.isEmpty([1, 2, 3, 4])).toBe(false);
729         });
730
731         it("should return false with boolean true", function() {
732             expect(Ext.isEmpty(true)).toBe(false);
733         });
734
735         it("should return false with boolean false", function() {
736             expect(Ext.isEmpty(false)).toBe(false);
737         });
738
739         it("should return false with string", function() {
740             expect(Ext.isEmpty("foo")).toBe(false);
741         });
742
743         it("should return true with empty string", function() {
744             expect(Ext.isEmpty("")).toBe(true);
745         });
746
747         it("should return true with empty string with allowBlank", function() {
748             expect(Ext.isEmpty("", true)).toBe(false);
749         });
750
751         it("should return false with number", function() {
752             expect(Ext.isEmpty(1)).toBe(false);
753         });
754
755         it("should return true with null", function() {
756             expect(Ext.isEmpty(null)).toBe(true);
757         });
758
759         it("should return true with undefined", function() {
760             expect(Ext.isEmpty(undefined)).toBe(true);
761         });
762
763         it("should return false with date", function() {
764             expect(Ext.isEmpty(new Date())).toBe(false);
765         });
766
767         it("should return false with empty object", function() {
768             expect(Ext.isEmpty({})).toBe(false);
769         });
770     });
771
772     describe("Ext.isFunction", function() {
773         beforeEach(function() {
774             // add global variable in whitelist
775             addGlobal("ExtSandbox1");
776         });
777
778         it("should return true with anonymous function", function() {
779             expect(Ext.isFunction(function(){})).toBe(true);
780         });
781
782         it("should return true with new Function syntax", function() {
783             expect(Ext.isFunction(Ext.functionFactory('return "";'))).toBe(true);
784         });
785
786         it("should return true with static function", function() {
787             expect(Ext.isFunction(Ext.emptyFn)).toBe(true);
788         });
789
790         it("should return true with instance function", function() {
791             var stupidClass = function() {},
792                 testObject;
793             stupidClass.prototype.testMe = function() {};
794             testObject = new stupidClass();
795
796             expect(Ext.isFunction(testObject.testMe)).toBe(true);
797         });
798
799         it("should return true with function on object", function() {
800             var o = {
801                 fn: function() {
802                 }
803             };
804
805             expect(Ext.isFunction(o.fn)).toBe(true);
806         });
807
808         it("should return false with empty array", function() {
809             expect(Ext.isFunction([])).toBe(false);
810         });
811
812         it("should return false with filled array", function() {
813             expect(Ext.isFunction([1, 2, 3, 4])).toBe(false);
814         });
815
816         it("should return false with boolean true", function() {
817             expect(Ext.isFunction(true)).toBe(false);
818         });
819
820         it("should return false with boolean false", function() {
821             expect(Ext.isFunction(false)).toBe(false);
822         });
823
824         it("should return false with string", function() {
825             expect(Ext.isFunction("foo")).toBe(false);
826         });
827
828         it("should return false with empty string", function() {
829             expect(Ext.isFunction("")).toBe(false);
830         });
831
832         it("should return false with number", function() {
833             expect(Ext.isFunction(1)).toBe(false);
834         });
835
836         it("should return false with null", function() {
837             expect(Ext.isFunction(null)).toBe(false);
838         });
839
840         it("should return false with undefined", function() {
841             expect(Ext.isFunction(undefined)).toBe(false);
842         });
843
844         it("should return false with date", function() {
845             expect(Ext.isFunction(new Date())).toBe(false);
846         });
847
848         it("should return false with empty object", function() {
849             expect(Ext.isFunction({})).toBe(false);
850         });
851
852         it("should return false with node list", function() {
853             expect(Ext.isFunction(document.getElementsByTagName('body'))).toBe(false);
854         });
855     });
856
857     describe("Ext.isNumber", function() {
858         it("should return true with zero", function() {
859             expect(Ext.isNumber(0)).toBe(true);
860         });
861
862         it("should return true with non zero", function() {
863             expect(Ext.isNumber(4)).toBe(true);
864         });
865
866         it("should return true with negative integer", function() {
867             expect(Ext.isNumber(-3)).toBe(true);
868         });
869
870         it("should return true with float", function() {
871             expect(Ext.isNumber(1.75)).toBe(true);
872         });
873
874         it("should return true with negative float", function() {
875             expect(Ext.isNumber(-4.75)).toBe(true);
876         });
877
878         it("should return true with Number.MAX_VALUE", function() {
879             expect(Ext.isNumber(Number.MAX_VALUE)).toBe(true);
880         });
881
882         it("should return true with Number.MIN_VALUE", function() {
883             expect(Ext.isNumber(Number.MIN_VALUE)).toBe(true);
884         });
885
886         it("should return true with Math.PI", function() {
887             expect(Ext.isNumber(Math.PI)).toBe(true);
888         });
889
890         it("should return true with Number() contructor", function() {
891             expect(Ext.isNumber(Number('3.1'))).toBe(true);
892         });
893
894         it("should return false with NaN", function() {
895             expect(Ext.isNumber(Number.NaN)).toBe(false);
896         });
897
898         it("should return false with Number.POSITIVE_INFINITY", function() {
899             expect(Ext.isNumber(Number.POSITIVE_INFINITY)).toBe(false);
900         });
901
902         it("should return false with Number.NEGATIVE_INFINITY", function() {
903             expect(Ext.isNumber(Number.NEGATIVE_INFINITY)).toBe(false);
904         });
905
906         it("should return false with empty array", function() {
907             expect(Ext.isNumber([])).toBe(false);
908         });
909
910         it("should return false with filled array", function() {
911             expect(Ext.isNumber([1, 2, 3, 4])).toBe(false);
912         });
913
914         it("should return false with boolean true", function() {
915             expect(Ext.isNumber(true)).toBe(false);
916         });
917
918         it("should return false with boolean false", function() {
919             expect(Ext.isNumber(false)).toBe(false);
920         });
921
922         it("should return false with string", function() {
923             expect(Ext.isNumber("foo")).toBe(false);
924         });
925
926         it("should return false with empty string", function() {
927             expect(Ext.isNumber("")).toBe(false);
928         });
929
930         it("should return false with string containing a number", function() {
931             expect(Ext.isNumber("1.0")).toBe(false);
932         });
933
934         it("should return false with undefined", function() {
935             expect(Ext.isNumber(undefined)).toBe(false);
936         });
937
938         it("should return false with date", function() {
939             expect(Ext.isNumber(new Date())).toBe(false);
940         });
941
942         it("should return false with empty object", function() {
943             expect(Ext.isNumber({})).toBe(false);
944         });
945
946         it("should return false with node list", function() {
947             expect(Ext.isNumber(document.getElementsByTagName('body'))).toBe(false);
948         });
949     });
950
951     describe("Ext.isObject", function() {
952         it("should return false with empty array", function() {
953             expect(Ext.isObject([])).toBe(false);
954         });
955
956         it("should return false with filled array", function() {
957             expect(Ext.isObject([1, 2, 3, 4])).toBe(false);
958         });
959
960         it("should return false with boolean true", function() {
961             expect(Ext.isObject(true)).toBe(false);
962         });
963
964         it("should return false with boolean false", function() {
965             expect(Ext.isObject(false)).toBe(false);
966         });
967
968         it("should return false with string", function() {
969             expect(Ext.isObject("foo")).toBe(false);
970         });
971
972         it("should return false with empty string", function() {
973             expect(Ext.isObject("")).toBe(false);
974         });
975
976         it("should return false with number", function() {
977             expect(Ext.isObject(1)).toBe(false);
978         });
979
980         it("should return false with null", function() {
981             expect(Ext.isObject(null)).toBe(false);
982         });
983
984         it("should return false with undefined", function() {
985             expect(Ext.isObject(undefined)).toBe(false);
986         });
987
988         it("should return false with date", function() {
989             expect(Ext.isObject(new Date())).toBe(false);
990         });
991
992         it("should return true with empty object", function() {
993             expect(Ext.isObject({})).toBe(true);
994         });
995
996         it("should return false with a DOM node", function() {
997             expect(Ext.isObject(document.body)).toBe(false);
998         });
999
1000         it("should return false with a Text node", function() {
1001             expect(Ext.isObject(document.createTextNode('test'))).toBe(false);
1002         });
1003
1004         it("should return true with object with properties", function() {
1005             expect(Ext.isObject({
1006                 foo: 1
1007             })).toBe(true);
1008         });
1009
1010         it("should return true with object instance", function() {
1011             var stupidClass = function() {};
1012
1013             expect(Ext.isObject(new stupidClass())).toBe(true);
1014         });
1015
1016         it("should return true with new Object syntax", function() {
1017             expect(Ext.isObject(new Object())).toBe(true);
1018         });
1019
1020         it("should return false with dom element", function() {
1021             expect(Ext.isObject(document.body)).toBe(false);
1022         });
1023     });
1024
1025     describe("Ext.isPrimitive", function() {
1026         it("should return true with integer", function() {
1027             expect(Ext.isPrimitive(1)).toBe(true);
1028         });
1029
1030         it("should return true with negative integer", function() {
1031             expect(Ext.isPrimitive(-21)).toBe(true);
1032         });
1033
1034         it("should return true with float", function() {
1035             expect(Ext.isPrimitive(2.1)).toBe(true);
1036         });
1037
1038         it("should return true with negative float", function() {
1039             expect(Ext.isPrimitive(-12.1)).toBe(true);
1040         });
1041
1042         it("should return true with Number.MAX_VALUE", function() {
1043             expect(Ext.isPrimitive(Number.MAX_VALUE)).toBe(true);
1044         });
1045
1046         it("should return true with Math.PI", function() {
1047             expect(Ext.isPrimitive(Math.PI)).toBe(true);
1048         });
1049
1050         it("should return true with empty string", function() {
1051             expect(Ext.isPrimitive("")).toBe(true);
1052         });
1053
1054         it("should return true with non empty string", function() {
1055             expect(Ext.isPrimitive("foo")).toBe(true);
1056         });
1057
1058         it("should return true with boolean true", function() {
1059             expect(Ext.isPrimitive(true)).toBe(true);
1060         });
1061
1062         it("should return true with boolean false", function() {
1063             expect(Ext.isPrimitive(false)).toBe(true);
1064         });
1065
1066         it("should return false with null", function() {
1067             expect(Ext.isPrimitive(null)).toBe(false);
1068         });
1069
1070         it("should return false with undefined", function() {
1071             expect(Ext.isPrimitive(undefined)).toBe(false);
1072         });
1073
1074         it("should return false with object", function() {
1075             expect(Ext.isPrimitive({})).toBe(false);
1076         });
1077
1078         it("should return false with object instance", function() {
1079             var stupidClass = function() {};
1080             expect(Ext.isPrimitive(new stupidClass())).toBe(false);
1081         });
1082
1083         it("should return false with array", function() {
1084             expect(Ext.isPrimitive([])).toBe(false);
1085         });
1086     });
1087
1088     describe("Ext.isString", function() {
1089         it("should return true with empty string", function() {
1090             expect(Ext.isString("")).toBe(true);
1091         });
1092
1093         it("should return true with non empty string", function() {
1094             expect(Ext.isString("foo")).toBe(true);
1095         });
1096
1097         it("should return true with String() syntax", function() {
1098             expect(Ext.isString(String(""))).toBe(true);
1099         });
1100
1101         it("should return false with new String() syntax", function() { //should return an object that wraps the primitive
1102             expect(Ext.isString(new String(""))).toBe(false);
1103         });
1104
1105         it("should return false with number", function() {
1106             expect(Ext.isString(1)).toBe(false);
1107         });
1108
1109         it("should return false with boolean", function() {
1110             expect(Ext.isString(true)).toBe(false);
1111         });
1112
1113         it("should return false with null", function() {
1114             expect(Ext.isString(null)).toBe(false);
1115         });
1116
1117         it("should return false with undefined", function() {
1118             expect(Ext.isString(undefined)).toBe(false);
1119         });
1120
1121         it("should return false with array", function() {
1122             expect(Ext.isString([])).toBe(false);
1123         });
1124
1125         it("should return false with object", function() {
1126             expect(Ext.isString({})).toBe(false);
1127         });
1128     });
1129
1130     describe("Ext.namespace", function() {
1131         var w = window;
1132
1133         it("should have an alias named ns", function() {
1134             expect(Ext.ns).toEqual(Ext.namespace);
1135         });
1136
1137         it("should create a single top level namespace", function() {
1138             Ext.namespace('FooTest1');
1139
1140             expect(w.FooTest1).toBeDefined();
1141
1142             if (jasmine.browser.isIE6 || jasmine.browser.isIE7 || jasmine.browser.isIE8) {
1143                 w.FooTest1 = undefined;
1144             } else {
1145                 delete w.FooTest1;
1146             }
1147         });
1148
1149         it("should create multiple top level namespace", function() {
1150             Ext.namespace('FooTest2', 'FooTest3', 'FooTest4');
1151
1152             expect(w.FooTest2).toBeDefined();
1153             expect(w.FooTest3).toBeDefined();
1154             expect(w.FooTest4).toBeDefined();
1155
1156             if (jasmine.browser.isIE6 || jasmine.browser.isIE7 || jasmine.browser.isIE8) {
1157                 w.FooTest2 = undefined;
1158                 w.FooTest3 = undefined;
1159                 w.FooTest4 = undefined;
1160             } else {
1161                 delete w.FooTest2;
1162                 delete w.FooTest3;
1163                 delete w.FooTest4;
1164             }
1165         });
1166
1167         it("should create a chain of namespaces, starting from a top level", function() {
1168             Ext.namespace('FooTest5', 'FooTest5.ns1', 'FooTest5.ns1.ns2', 'FooTest5.ns1.ns2.ns3');
1169
1170             expect(w.FooTest5).toBeDefined();
1171             expect(w.FooTest5.ns1).toBeDefined();
1172             expect(w.FooTest5.ns1.ns2).toBeDefined();
1173             expect(w.FooTest5.ns1.ns2.ns3).toBeDefined();
1174
1175             if (jasmine.browser.isIE6 || jasmine.browser.isIE7 || jasmine.browser.isIE8) {
1176                 w.FooTest5 = undefined;
1177             } else {
1178                 delete w.FooTest5;
1179             }
1180         });
1181
1182         it("should create lower level namespaces without first defining the top level", function() {
1183             Ext.namespace('FooTest6.ns1', 'FooTest7.ns2');
1184
1185             expect(w.FooTest6).toBeDefined();
1186             expect(w.FooTest6.ns1).toBeDefined();
1187             expect(w.FooTest7).toBeDefined();
1188             expect(w.FooTest7.ns2).toBeDefined();
1189
1190             if (jasmine.browser.isIE6 || jasmine.browser.isIE7 || jasmine.browser.isIE8) {
1191                 w.FooTest6 = undefined;
1192                 w.FooTest7 = undefined;
1193             } else {
1194                 delete w.FooTest6;
1195                 delete w.FooTest7;
1196             }
1197         });
1198
1199         it("should create a lower level namespace without defining the middle level", function() {
1200             Ext.namespace('FooTest8', 'FooTest8.ns1.ns2');
1201
1202             expect(w.FooTest8).toBeDefined();
1203             expect(w.FooTest8.ns1).toBeDefined();
1204             expect(w.FooTest8.ns1.ns2).toBeDefined();
1205
1206             if (jasmine.browser.isIE6 || jasmine.browser.isIE7 || jasmine.browser.isIE8) {
1207                 w.FooTest8 = undefined;
1208             } else {
1209                 delete w.FooTest8;
1210             }
1211         });
1212
1213         it ("should not overwritte existing namespace", function() {
1214             Ext.namespace('FooTest9');
1215
1216             FooTest9.prop1 = 'foo';
1217
1218             Ext.namespace('FooTest9');
1219
1220             expect(FooTest9.prop1).toEqual("foo");
1221
1222             if (jasmine.browser.isIE6 || jasmine.browser.isIE7 || jasmine.browser.isIE8) {
1223                 w.FooTest9 = undefined;
1224             } else {
1225                 delete w.FooTest9;
1226             }
1227         });
1228     });
1229
1230
1231 });