3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
15 describe("Ext", function() {
17 describe("Ext.global", function() {
18 it("should return the global scope", function() {
19 expect(Ext.global).toBe((function(){ return this;}).call());
23 describe("Ext.apply", function() {
26 beforeEach(function() {
32 this.myMethodCalled = true;
34 toString: function() {
35 this.myToStringCalled = true;
40 it("should copy normal properties", function() {
44 otherThing: 'not cool',
48 expect(origin.name).toEqual('newName');
49 expect(origin.items).toEqual([4,5,6]);
50 expect(origin.something).toEqual('cool');
51 expect(origin.otherThing).toEqual('not cool');
52 expect(origin.isCool).toEqual(false);
55 it("should copy functions", function() {
58 this.newMethodCalled = true;
64 expect(origin.myMethodCalled).not.toBeDefined();
65 expect(origin.newMethodCalled).toBeTruthy();
68 it("should copy non-enumerables", function() {
70 toString: function() {
71 this.newToStringCalled = true;
77 expect(origin.myToStringCalled).not.toBeDefined();
78 expect(origin.newToStringCalled).toBeTruthy();
81 it("should apply properties and return an object", function() {
93 it("should change the reference of the object", function() {
106 it("should overwrite properties", function() {
122 it("should use default", function() {
140 it("should override all defaults", function() {
155 it("should return null if null is passed as first argument", function() {
156 expect(Ext.apply(null, {})).toBeNull();
159 it("should return the object if second argument is no defined", function() {
163 expect(Ext.apply(o)).toEqual(o);
166 it("should override valueOf", function() {
167 o = Ext.apply({}, {valueOf: 1});
169 expect(o.valueOf).toEqual(1);
172 it("should override toString", function() {
173 o = Ext.apply({}, {toString: 3});
175 expect(o.toString).toEqual(3);
180 describe("Ext.emptyFn", function() {
181 it("should return undefined without params", function() {
182 expect(Ext.emptyFn()).toBeUndefined();
185 it("should return undefined if you pass params", function() {
186 expect(Ext.emptyFn('aaaa', 'bbbbb')).toBeUndefined();
190 describe("Ext.iterate", function() {
193 beforeEach(function() {
194 itFn = jasmine.createSpy();
197 describe("iterate object", function() {
200 beforeEach(function() {
208 describe("if itFn does not return false", function() {
209 beforeEach(function() {
210 Ext.iterate(o, itFn);
213 it("should call the iterate function 3 times", function () {
214 expect(itFn.callCount).toEqual(3);
217 it("should call the iterate function with correct arguments", function () {
218 expect(itFn.calls[0].args).toEqual(["n1", 11, o]);
219 expect(itFn.calls[1].args).toEqual(["n2", 13, o]);
220 expect(itFn.calls[2].args).toEqual(["n3", 18, o]);
224 describe("if itFn return false", function() {
225 beforeEach(function() {
226 itFn.andReturn(false);
227 Ext.iterate(o, itFn);
230 it("should stop iteration if function return false", function() {
231 itFn.andReturn(false);
233 expect(itFn.calls.length).toEqual(1);
238 describe("do nothing on an empty object", function() {
241 beforeEach(function() {
243 Ext.iterate(o, itFn);
246 it("should not call the iterate function", function () {
247 expect(itFn).not.toHaveBeenCalled();
252 describe("iterate array", function() {
255 beforeEach(function() {
259 describe("if itFn does not return false", function() {
260 beforeEach(function() {
261 Ext.iterate(arr, itFn);
264 it("should call the iterate function 4 times", function () {
265 expect(itFn.callCount).toEqual(4);
268 it("should call the iterate function with correct arguments", function () {
269 expect(itFn.calls[0].args).toEqual([6, 0, arr]);
270 expect(itFn.calls[1].args).toEqual([7, 1, arr]);
271 expect(itFn.calls[2].args).toEqual([8, 2, arr]);
272 expect(itFn.calls[3].args).toEqual([9, 3, arr]);
276 describe("if itFn return false", function() {
277 beforeEach(function() {
278 itFn.andReturn(false);
279 Ext.iterate(arr, itFn);
282 it("should stop iteration if function return false", function() {
283 itFn.andReturn(false);
285 expect(itFn.calls.length).toEqual(1);
290 describe("do nothing on an empty array", function() {
293 beforeEach(function() {
295 Ext.iterate(arr, itFn);
298 it("should not call the iterate function", function () {
299 expect(itFn).not.toHaveBeenCalled();
305 describe("Ext.applyIf", function(){
308 it("should apply properties and return an object with an empty destination object", function() {
309 o = Ext.applyIf({}, {
320 it("should not override default properties", function() {
332 it("should not override default properties with mixing properties", function() {
348 it("should change the reference of the object", function() {
361 it("should return null if null is passed as first argument", function() {
362 expect(Ext.applyIf(null, {})).toBeNull();
365 it("should return the object if second argument is no defined", function() {
370 expect(Ext.applyIf(o)).toEqual(o);
375 describe("Ext.extend", function() {
376 var Dude, Awesome, david;
378 beforeEach(function() {
379 Dude = Ext.extend(Object, {
380 constructor: function(config){
381 Ext.apply(this, config);
382 this.isBadass = false;
386 Awesome = Ext.extend(Dude, {
387 constructor: function(){
388 Awesome.superclass.constructor.apply(this, arguments);
389 this.isBadass = true;
393 david = new Awesome({
398 it("should throw an error if superclass isn't defined", function() {
400 Ext.extend(undefined, {});
401 }).toRaiseExtError("Attempting to extend from a class which has not been loaded on the page.");
404 it("should create a superclass that return the original classe", function() {
405 expect(david.superclass).toEqual(Dude.prototype);
408 it("should add override method", function() {
409 expect(typeof david.override === 'function').toBe(true);
412 it("should override redefined methods", function() {
413 expect(david.isBadass).toBe(true);
416 it("should keep new properties", function() {
417 expect(david.davis).toEqual('isAwesome');
421 describe("Ext.override", function(){
425 beforeEach(function(){
426 Dude = function(){}; // avoid to directly override Object class
427 extApplySpy = spyOn(Ext, "apply");
430 it("should apply override", function(){
431 var override = {foo: true};
433 Ext.override(Dude, override);
435 expect(extApplySpy).toHaveBeenCalledWith(Dude.prototype, override);
439 describe("Ext.valueFrom", function() {
440 var value, defaultValue;
442 describe("with allowBlank", function() {
443 describe("and an empty string", function() {
444 it("should return the value", function() {
445 expect(Ext.valueFrom('', 'aaa', true)).toBe('');
449 describe("and a string", function() {
450 it("should return the value", function() {
451 expect(Ext.valueFrom('bbb', 'aaa', true)).toBe('bbb');
455 describe("and an undefined value", function() {
456 it("should return the default value", function() {
457 expect(Ext.valueFrom(undefined, 'aaa', true)).toBe('aaa');
461 describe("and a null value", function() {
462 it("should return the default value", function() {
463 expect(Ext.valueFrom(null, 'aaa', true)).toBe('aaa');
467 describe("and a 0 value", function() {
468 it("should return the value", function() {
469 expect(Ext.valueFrom(0, 'aaa', true)).toBe(0);
474 describe("without allowBlank", function() {
475 describe("and an empty string", function() {
476 it("should return the default value", function() {
477 expect(Ext.valueFrom('', 'aaa')).toBe('aaa');
481 describe("and a string", function() {
482 it("should return the value", function() {
483 expect(Ext.valueFrom('bbb', 'aaa')).toBe('bbb');
487 describe("and an undefined value", function() {
488 it("should return the default value", function() {
489 expect(Ext.valueFrom(undefined, 'aaa')).toBe('aaa');
493 describe("and a null value", function() {
494 it("should return the default value", function() {
495 expect(Ext.valueFrom(null, 'aaa')).toBe('aaa');
499 describe("and a 0 value", function() {
500 it("should return the value", function() {
501 expect(Ext.valueFrom(0, 'aaa')).toBe(0);
507 describe("Ext.typeOf", function() {
508 it("should return null", function() {
509 expect(Ext.typeOf(null)).toEqual('null');
511 it("should return undefined", function() {
512 expect(Ext.typeOf(undefined)).toEqual('undefined');
514 it("should return undefined", function() {
515 expect(Ext.typeOf(window.someWeirdPropertyThatDoesntExist)).toEqual('undefined');
517 it("should return string", function() {
518 expect(Ext.typeOf('')).toEqual('string');
520 it("should return string", function() {
521 expect(Ext.typeOf('something')).toEqual('string');
523 it("should return string", function() {
524 expect(Ext.typeOf('1.2')).toEqual('string');
526 it("should return number", function() {
527 expect(Ext.typeOf(1)).toEqual('number');
529 it("should return number", function() {
530 expect(Ext.typeOf(1.2)).toEqual('number');
532 it("should return boolean", function() {
533 expect(Ext.typeOf(true)).toEqual('boolean');
535 it("should return boolean", function() {
536 expect(Ext.typeOf(false)).toEqual('boolean');
538 it("should return array", function() {
539 expect(Ext.typeOf([1,2,3])).toEqual('array');
541 it("should return array", function() {
542 expect(Ext.typeOf(new Array(1,2,3))).toEqual('array');
544 it("should return function 1", function() {
545 expect(Ext.typeOf(function(){})).toEqual('function');
547 // Don't run this test in IE
548 if (typeof alert === 'function') {
549 it("should return function 2", function() {
550 expect(Ext.typeOf(prompt)).toEqual('function');
553 it("should return function 3", function() {
554 expect(Ext.typeOf(new Function())).toEqual('function');
556 it("should return regexp 1", function() {
557 expect(Ext.typeOf(/test/)).toEqual('regexp');
559 it("should return regexp 2", function() {
560 expect(Ext.typeOf(new RegExp('test'))).toEqual('regexp');
562 it("should return date", function() {
563 expect(Ext.typeOf(new Date())).toEqual('date');
565 it("should return textnode", function() {
566 expect(Ext.typeOf(document.createTextNode('tada'))).toEqual('textnode');
568 it("should return whitespace", function() {
569 expect(Ext.typeOf(document.createTextNode(' '))).toEqual('whitespace');
571 it("should return whitespace", function() {
572 expect(Ext.typeOf(document.createTextNode(' '))).toEqual('whitespace');
574 it("should return element", function() {
575 expect(Ext.typeOf(document.getElementsByTagName('body')[0])).toEqual('element');
577 it("should return element", function() {
578 expect(Ext.typeOf(document.createElement('button'))).toEqual('element');
580 it("should return element", function() {
581 expect(Ext.typeOf(new Image())).toEqual('element');
583 it("should return object 1", function() {
584 expect(Ext.typeOf({some: 'stuff'})).toEqual('object');
586 it("should return object 2", function() {
587 expect(Ext.typeOf(new Object())).toEqual('object');
589 it("should return object 3", function() {
590 expect(Ext.typeOf(window)).toEqual('object');
592 it("should return boolean", function() {
593 expect(Ext.typeOf(new Boolean(true))).toEqual('boolean');
595 it("should return number", function() {
596 expect(Ext.typeOf(new Number(1.2))).toEqual('number');
600 describe("Ext.isIterable", function() {
601 it("should return true with empty array", function() {
602 expect(Ext.isIterable([])).toBe(true);
605 it("should return true with filled array", function() {
606 expect(Ext.isIterable([1, 2, 3, 4])).toBe(true);
609 it("should return false with boolean true", function() {
610 expect(Ext.isIterable(true)).toBe(false);
613 it("should return false with boolean false", function() {
614 expect(Ext.isIterable(false)).toBe(false);
617 it("should return false with string", function() {
618 expect(Ext.isIterable("foo")).toBe(false);
621 it("should return false with empty string", function() {
622 expect(Ext.isIterable("")).toBe(false);
625 it("should return false with number", function() {
626 expect(Ext.isIterable(1)).toBe(false);
629 it("should return false with null", function() {
630 expect(Ext.isIterable(null)).toBe(false);
633 it("should return false with undefined", function() {
634 expect(Ext.isIterable(undefined)).toBe(false);
637 it("should return false with date", function() {
638 expect(Ext.isIterable(new Date())).toBe(false);
641 it("should return false with empty object", function() {
642 expect(Ext.isIterable({})).toBe(false);
645 it("should return true with node list", function() {
646 expect(Ext.isIterable(document.getElementsByTagName('body'))).toBe(true);
649 it("should return true with html collection", function() {
650 expect(Ext.isIterable(document.images)).toBe(true);
654 describe("Ext.isArray", function() {
655 it("should return true with empty array", function() {
656 expect(Ext.isArray([])).toBe(true);
659 it("should return true with filled array", function() {
660 expect(Ext.isArray([1, 2, 3, 4])).toBe(true);
663 it("should return false with boolean true", function() {
664 expect(Ext.isArray(true)).toBe(false);
667 it("should return false with boolean false", function() {
668 expect(Ext.isArray(false)).toBe(false);
671 it("should return false with string", function() {
672 expect(Ext.isArray("foo")).toBe(false);
675 it("should return false with empty string", function() {
676 expect(Ext.isArray("")).toBe(false);
679 it("should return false with number", function() {
680 expect(Ext.isArray(1)).toBe(false);
683 it("should return false with null", function() {
684 expect(Ext.isArray(null)).toBe(false);
687 it("should return false with undefined", function() {
688 expect(Ext.isArray(undefined)).toBe(false);
691 it("should return false with date", function() {
692 expect(Ext.isArray(new Date())).toBe(false);
695 it("should return false with empty object", function() {
696 expect(Ext.isArray({})).toBe(false);
699 it("should return false with node list", function() {
700 expect(Ext.isArray(document.getElementsByTagName('body'))).toBe(false);
703 it("should return false with custom class that has a length property", function() {
704 var C = Ext.extend(Object, {
707 expect(Ext.isArray(new C())).toBe(false);
710 it("should return false with element", function() {
711 expect(Ext.isArray(Ext.getBody().dom)).toBe(false);
715 describe("Ext.isBoolean", function() {
716 it("should return false with empty array", function() {
717 expect(Ext.isBoolean([])).toBe(false);
720 it("should return false with filled array", function() {
721 expect(Ext.isBoolean([1, 2, 3, 4])).toBe(false);
724 it("should return true with boolean true", function() {
725 expect(Ext.isBoolean(true)).toBe(true);
728 it("should return true with boolean false", function() {
729 expect(Ext.isBoolean(false)).toBe(true);
732 it("should return false with string", function() {
733 expect(Ext.isBoolean("foo")).toBe(false);
736 it("should return false with empty string", function() {
737 expect(Ext.isBoolean("")).toBe(false);
740 it("should return false with number", function() {
741 expect(Ext.isBoolean(1)).toBe(false);
744 it("should return false with null", function() {
745 expect(Ext.isBoolean(null)).toBe(false);
748 it("should return false with undefined", function() {
749 expect(Ext.isBoolean(undefined)).toBe(false);
752 it("should return false with date", function() {
753 expect(Ext.isBoolean(new Date())).toBe(false);
756 it("should return false with empty object", function() {
757 expect(Ext.isBoolean({})).toBe(false);
760 it("should return false with node list", function() {
761 expect(Ext.isBoolean(document.getElementsByTagName('body'))).toBe(false);
764 it("should return false with element", function() {
765 expect(Ext.isArray(Ext.getBody().dom)).toBe(false);
769 describe("Ext.isDate", function() {
770 it("should return false with empty array", function() {
771 expect(Ext.isDate([])).toBe(false);
774 it("should return false with filled array", function() {
775 expect(Ext.isDate([1, 2, 3, 4])).toBe(false);
778 it("should return false with boolean true", function() {
779 expect(Ext.isDate(true)).toBe(false);
782 it("should return false with boolean false", function() {
783 expect(Ext.isDate(false)).toBe(false);
786 it("should return false with string", function() {
787 expect(Ext.isDate("foo")).toBe(false);
790 it("should return false with empty string", function() {
791 expect(Ext.isDate("")).toBe(false);
794 it("should return false with number", function() {
795 expect(Ext.isDate(1)).toBe(false);
798 it("should return false with null", function() {
799 expect(Ext.isDate(null)).toBe(false);
802 it("should return false with undefined", function() {
803 expect(Ext.isDate(undefined)).toBe(false);
806 it("should return true with date", function() {
807 expect(Ext.isDate(new Date())).toBe(true);
810 it("should return false with empty object", function() {
811 expect(Ext.isDate({})).toBe(false);
814 it("should return false with node list", function() {
815 expect(Ext.isDate(document.getElementsByTagName('body'))).toBe(false);
818 it("should return false with element", function() {
819 expect(Ext.isDate(Ext.getBody().dom)).toBe(false);
823 describe("Ext.isDefined", function() {
824 it("should return true with empty array", function() {
825 expect(Ext.isDefined([])).toBe(true);
828 it("should return true with filled array", function() {
829 expect(Ext.isDefined([1, 2, 3, 4])).toBe(true);
832 it("should return true with boolean true", function() {
833 expect(Ext.isDefined(true)).toBe(true);
836 it("should return true with boolean false", function() {
837 expect(Ext.isDefined(false)).toBe(true);
840 it("should return true with string", function() {
841 expect(Ext.isDefined("foo")).toBe(true);
844 it("should return true with empty string", function() {
845 expect(Ext.isDefined("")).toBe(true);
848 it("should return true with number", function() {
849 expect(Ext.isDefined(1)).toBe(true);
852 it("should return true with null", function() {
853 expect(Ext.isDefined(null)).toBe(true);
856 it("should return false with undefined", function() {
857 expect(Ext.isDefined(undefined)).toBe(false);
860 it("should return true with date", function() {
861 expect(Ext.isDefined(new Date())).toBe(true);
864 it("should return true with empty object", function() {
865 expect(Ext.isDefined({})).toBe(true);
868 it("should return true with node list", function() {
869 expect(Ext.isDefined(document.getElementsByTagName('body'))).toBe(true);
872 it("should return true with element", function() {
873 expect(Ext.isDefined(Ext.getBody().dom)).toBe(true);
877 describe("Ext.isElement", function() {
878 it("should return false with empty array", function() {
879 expect(Ext.isElement([])).toBe(false);
882 it("should return false with filled array", function() {
883 expect(Ext.isElement([1, 2, 3, 4])).toBe(false);
886 it("should return false with boolean true", function() {
887 expect(Ext.isElement(true)).toBe(false);
890 it("should return false with boolean false", function() {
891 expect(Ext.isElement(false)).toBe(false);
894 it("should return false with string", function() {
895 expect(Ext.isElement("foo")).toBe(false);
898 it("should return false with empty string", function() {
899 expect(Ext.isElement("")).toBe(false);
902 it("should return false with number", function() {
903 expect(Ext.isElement(1)).toBe(false);
906 it("should return false with null", function() {
907 expect(Ext.isElement(null)).toBe(false);
910 it("should return false with undefined", function() {
911 expect(Ext.isElement(undefined)).toBe(false);
914 it("should return false with date", function() {
915 expect(Ext.isElement(new Date())).toBe(false);
918 it("should return false with empty object", function() {
919 expect(Ext.isElement({})).toBe(false);
922 it("should return false with node list", function() {
923 expect(Ext.isElement(document.getElementsByTagName('body'))).toBe(false);
926 it("should return true with element", function() {
927 expect(Ext.isElement(Ext.getBody().dom)).toBe(true);
930 it("should return false with Ext.Element", function() {
931 expect(Ext.isElement(Ext.getBody())).toBe(false);
934 it("should return false with TextNode", function() {
935 var textNode = document.createTextNode('foobar');
936 document.body.appendChild(textNode);
937 expect(Ext.isElement(textNode)).toBe(false);
938 document.body.removeChild(textNode);
942 describe("Ext.isEmpty", function() {
943 it("should return true with empty array", function() {
944 expect(Ext.isEmpty([])).toBe(true);
947 it("should return false with filled array", function() {
948 expect(Ext.isEmpty([1, 2, 3, 4])).toBe(false);
951 it("should return false with boolean true", function() {
952 expect(Ext.isEmpty(true)).toBe(false);
955 it("should return false with boolean false", function() {
956 expect(Ext.isEmpty(false)).toBe(false);
959 it("should return false with string", function() {
960 expect(Ext.isEmpty("foo")).toBe(false);
963 it("should return true with empty string", function() {
964 expect(Ext.isEmpty("")).toBe(true);
967 it("should return true with empty string with allowBlank", function() {
968 expect(Ext.isEmpty("", true)).toBe(false);
971 it("should return false with number", function() {
972 expect(Ext.isEmpty(1)).toBe(false);
975 it("should return true with null", function() {
976 expect(Ext.isEmpty(null)).toBe(true);
979 it("should return true with undefined", function() {
980 expect(Ext.isEmpty(undefined)).toBe(true);
983 it("should return false with date", function() {
984 expect(Ext.isEmpty(new Date())).toBe(false);
987 it("should return false with empty object", function() {
988 expect(Ext.isEmpty({})).toBe(false);
992 describe("Ext.isFunction", function() {
993 beforeEach(function() {
994 // add global variable in whitelist
995 addGlobal("ExtBox1");
998 it("should return true with anonymous function", function() {
999 expect(Ext.isFunction(function(){})).toBe(true);
1002 it("should return true with new Function syntax", function() {
1003 expect(Ext.isFunction(Ext.functionFactory('return "";'))).toBe(true);
1006 it("should return true with static function", function() {
1007 expect(Ext.isFunction(Ext.emptyFn)).toBe(true);
1010 it("should return true with instance function", function() {
1011 var stupidClass = function() {},
1013 stupidClass.prototype.testMe = function() {};
1014 testObject = new stupidClass();
1016 expect(Ext.isFunction(testObject.testMe)).toBe(true);
1019 it("should return true with function on object", function() {
1025 expect(Ext.isFunction(o.fn)).toBe(true);
1028 it("should return false with empty array", function() {
1029 expect(Ext.isFunction([])).toBe(false);
1032 it("should return false with filled array", function() {
1033 expect(Ext.isFunction([1, 2, 3, 4])).toBe(false);
1036 it("should return false with boolean true", function() {
1037 expect(Ext.isFunction(true)).toBe(false);
1040 it("should return false with boolean false", function() {
1041 expect(Ext.isFunction(false)).toBe(false);
1044 it("should return false with string", function() {
1045 expect(Ext.isFunction("foo")).toBe(false);
1048 it("should return false with empty string", function() {
1049 expect(Ext.isFunction("")).toBe(false);
1052 it("should return false with number", function() {
1053 expect(Ext.isFunction(1)).toBe(false);
1056 it("should return false with null", function() {
1057 expect(Ext.isFunction(null)).toBe(false);
1060 it("should return false with undefined", function() {
1061 expect(Ext.isFunction(undefined)).toBe(false);
1064 it("should return false with date", function() {
1065 expect(Ext.isFunction(new Date())).toBe(false);
1068 it("should return false with empty object", function() {
1069 expect(Ext.isFunction({})).toBe(false);
1072 it("should return false with node list", function() {
1073 expect(Ext.isFunction(document.getElementsByTagName('body'))).toBe(false);
1077 describe("Ext.isNumber", function() {
1078 it("should return true with zero", function() {
1079 expect(Ext.isNumber(0)).toBe(true);
1082 it("should return true with non zero", function() {
1083 expect(Ext.isNumber(4)).toBe(true);
1086 it("should return true with negative integer", function() {
1087 expect(Ext.isNumber(-3)).toBe(true);
1090 it("should return true with float", function() {
1091 expect(Ext.isNumber(1.75)).toBe(true);
1094 it("should return true with negative float", function() {
1095 expect(Ext.isNumber(-4.75)).toBe(true);
1098 it("should return true with Number.MAX_VALUE", function() {
1099 expect(Ext.isNumber(Number.MAX_VALUE)).toBe(true);
1102 it("should return true with Number.MIN_VALUE", function() {
1103 expect(Ext.isNumber(Number.MIN_VALUE)).toBe(true);
1106 it("should return true with Math.PI", function() {
1107 expect(Ext.isNumber(Math.PI)).toBe(true);
1110 it("should return true with Number() contructor", function() {
1111 expect(Ext.isNumber(Number('3.1'))).toBe(true);
1114 it("should return false with NaN", function() {
1115 expect(Ext.isNumber(Number.NaN)).toBe(false);
1118 it("should return false with Number.POSITIVE_INFINITY", function() {
1119 expect(Ext.isNumber(Number.POSITIVE_INFINITY)).toBe(false);
1122 it("should return false with Number.NEGATIVE_INFINITY", function() {
1123 expect(Ext.isNumber(Number.NEGATIVE_INFINITY)).toBe(false);
1126 it("should return false with empty array", function() {
1127 expect(Ext.isNumber([])).toBe(false);
1130 it("should return false with filled array", function() {
1131 expect(Ext.isNumber([1, 2, 3, 4])).toBe(false);
1134 it("should return false with boolean true", function() {
1135 expect(Ext.isNumber(true)).toBe(false);
1138 it("should return false with boolean false", function() {
1139 expect(Ext.isNumber(false)).toBe(false);
1142 it("should return false with string", function() {
1143 expect(Ext.isNumber("foo")).toBe(false);
1146 it("should return false with empty string", function() {
1147 expect(Ext.isNumber("")).toBe(false);
1150 it("should return false with string containing a number", function() {
1151 expect(Ext.isNumber("1.0")).toBe(false);
1154 it("should return false with undefined", function() {
1155 expect(Ext.isNumber(undefined)).toBe(false);
1158 it("should return false with date", function() {
1159 expect(Ext.isNumber(new Date())).toBe(false);
1162 it("should return false with empty object", function() {
1163 expect(Ext.isNumber({})).toBe(false);
1166 it("should return false with node list", function() {
1167 expect(Ext.isNumber(document.getElementsByTagName('body'))).toBe(false);
1171 describe("Ext.isNumeric", function() {
1172 it("should return true with zero", function() {
1173 expect(Ext.isNumeric(0)).toBe(true);
1176 it("should return true with non zero", function() {
1177 expect(Ext.isNumeric(4)).toBe(true);
1180 it("should return true with negative integer", function() {
1181 expect(Ext.isNumeric(-3)).toBe(true);
1184 it("should return true with float", function() {
1185 expect(Ext.isNumeric(1.75)).toBe(true);
1188 it("should return true with negative float", function() {
1189 expect(Ext.isNumeric(-4.75)).toBe(true);
1192 it("should return true with Number.MAX_VALUE", function() {
1193 expect(Ext.isNumeric(Number.MAX_VALUE)).toBe(true);
1196 it("should return true with Number.MIN_VALUE", function() {
1197 expect(Ext.isNumeric(Number.MIN_VALUE)).toBe(true);
1200 it("should return true with Math.PI", function() {
1201 expect(Ext.isNumeric(Math.PI)).toBe(true);
1204 it("should return true with Number() contructor", function() {
1205 expect(Ext.isNumeric(Number('3.1'))).toBe(true);
1208 it("should return false with NaN", function() {
1209 expect(Ext.isNumeric(Number.NaN)).toBe(false);
1212 it("should return false with Number.POSITIVE_INFINITY", function() {
1213 expect(Ext.isNumeric(Number.POSITIVE_INFINITY)).toBe(false);
1216 it("should return false with Number.NEGATIVE_INFINITY", function() {
1217 expect(Ext.isNumeric(Number.NEGATIVE_INFINITY)).toBe(false);
1220 it("should return false with empty array", function() {
1221 expect(Ext.isNumeric([])).toBe(false);
1224 it("should return false with filled array", function() {
1225 expect(Ext.isNumeric([1, 2, 3, 4])).toBe(false);
1228 it("should return false with boolean true", function() {
1229 expect(Ext.isNumeric(true)).toBe(false);
1232 it("should return false with boolean false", function() {
1233 expect(Ext.isNumeric(false)).toBe(false);
1236 it("should return false with string", function() {
1237 expect(Ext.isNumeric("foo")).toBe(false);
1240 it("should return false with empty string", function() {
1241 expect(Ext.isNumeric("")).toBe(false);
1244 it("should return true with string containing a number", function() {
1245 expect(Ext.isNumeric("1.0")).toBe(true);
1248 it("should return false with undefined", function() {
1249 expect(Ext.isNumeric(undefined)).toBe(false);
1252 it("should return false with date", function() {
1253 expect(Ext.isNumeric(new Date())).toBe(false);
1256 it("should return false with empty object", function() {
1257 expect(Ext.isNumeric({})).toBe(false);
1260 it("should return false with node list", function() {
1261 expect(Ext.isNumeric(document.getElementsByTagName('body'))).toBe(false);
1265 describe("Ext.isObject", function() {
1266 it("should return false with empty array", function() {
1267 expect(Ext.isObject([])).toBe(false);
1270 it("should return false with filled array", function() {
1271 expect(Ext.isObject([1, 2, 3, 4])).toBe(false);
1274 it("should return false with boolean true", function() {
1275 expect(Ext.isObject(true)).toBe(false);
1278 it("should return false with boolean false", function() {
1279 expect(Ext.isObject(false)).toBe(false);
1282 it("should return false with string", function() {
1283 expect(Ext.isObject("foo")).toBe(false);
1286 it("should return false with empty string", function() {
1287 expect(Ext.isObject("")).toBe(false);
1290 it("should return false with number", function() {
1291 expect(Ext.isObject(1)).toBe(false);
1294 it("should return false with null", function() {
1295 expect(Ext.isObject(null)).toBe(false);
1298 it("should return false with undefined", function() {
1299 expect(Ext.isObject(undefined)).toBe(false);
1302 it("should return false with date", function() {
1303 expect(Ext.isObject(new Date())).toBe(false);
1306 it("should return true with empty object", function() {
1307 expect(Ext.isObject({})).toBe(true);
1310 it("should return false with a DOM node", function() {
1311 expect(Ext.isObject(document.body)).toBe(false);
1314 it("should return false with a Text node", function() {
1315 expect(Ext.isObject(document.createTextNode('test'))).toBe(false);
1318 it("should return true with object with properties", function() {
1319 expect(Ext.isObject({
1324 it("should return true with object instance", function() {
1325 var stupidClass = function() {};
1327 expect(Ext.isObject(new stupidClass())).toBe(true);
1330 it("should return true with new Object syntax", function() {
1331 expect(Ext.isObject(new Object())).toBe(true);
1334 it("should return false with dom element", function() {
1335 expect(Ext.isObject(document.body)).toBe(false);
1339 describe("Ext.isPrimitive", function() {
1340 it("should return true with integer", function() {
1341 expect(Ext.isPrimitive(1)).toBe(true);
1344 it("should return true with negative integer", function() {
1345 expect(Ext.isPrimitive(-21)).toBe(true);
1348 it("should return true with float", function() {
1349 expect(Ext.isPrimitive(2.1)).toBe(true);
1352 it("should return true with negative float", function() {
1353 expect(Ext.isPrimitive(-12.1)).toBe(true);
1356 it("should return true with Number.MAX_VALUE", function() {
1357 expect(Ext.isPrimitive(Number.MAX_VALUE)).toBe(true);
1360 it("should return true with Math.PI", function() {
1361 expect(Ext.isPrimitive(Math.PI)).toBe(true);
1364 it("should return true with empty string", function() {
1365 expect(Ext.isPrimitive("")).toBe(true);
1368 it("should return true with non empty string", function() {
1369 expect(Ext.isPrimitive("foo")).toBe(true);
1372 it("should return true with boolean true", function() {
1373 expect(Ext.isPrimitive(true)).toBe(true);
1376 it("should return true with boolean false", function() {
1377 expect(Ext.isPrimitive(false)).toBe(true);
1380 it("should return false with null", function() {
1381 expect(Ext.isPrimitive(null)).toBe(false);
1384 it("should return false with undefined", function() {
1385 expect(Ext.isPrimitive(undefined)).toBe(false);
1388 it("should return false with object", function() {
1389 expect(Ext.isPrimitive({})).toBe(false);
1392 it("should return false with object instance", function() {
1393 var stupidClass = function() {};
1394 expect(Ext.isPrimitive(new stupidClass())).toBe(false);
1397 it("should return false with array", function() {
1398 expect(Ext.isPrimitive([])).toBe(false);
1402 describe("Ext.isString", function() {
1403 it("should return true with empty string", function() {
1404 expect(Ext.isString("")).toBe(true);
1407 it("should return true with non empty string", function() {
1408 expect(Ext.isString("foo")).toBe(true);
1411 it("should return true with String() syntax", function() {
1412 expect(Ext.isString(String(""))).toBe(true);
1415 it("should return false with new String() syntax", function() { //should return an object that wraps the primitive
1416 expect(Ext.isString(new String(""))).toBe(false);
1419 it("should return false with number", function() {
1420 expect(Ext.isString(1)).toBe(false);
1423 it("should return false with boolean", function() {
1424 expect(Ext.isString(true)).toBe(false);
1427 it("should return false with null", function() {
1428 expect(Ext.isString(null)).toBe(false);
1431 it("should return false with undefined", function() {
1432 expect(Ext.isString(undefined)).toBe(false);
1435 it("should return false with array", function() {
1436 expect(Ext.isString([])).toBe(false);
1439 it("should return false with object", function() {
1440 expect(Ext.isString({})).toBe(false);
1444 describe("Ext.isTextNode", function() {
1445 it("should return false with empty array", function() {
1446 expect(Ext.isTextNode([])).toBe(false);
1449 it("should return false with filled array", function() {
1450 expect(Ext.isTextNode([1, 2, 3, 4])).toBe(false);
1453 it("should return false with boolean true", function() {
1454 expect(Ext.isTextNode(true)).toBe(false);
1457 it("should return false with boolean false", function() {
1458 expect(Ext.isTextNode(false)).toBe(false);
1461 it("should return false with string", function() {
1462 expect(Ext.isTextNode("foo")).toBe(false);
1465 it("should return false with empty string", function() {
1466 expect(Ext.isTextNode("")).toBe(false);
1469 it("should return false with number", function() {
1470 expect(Ext.isTextNode(1)).toBe(false);
1473 it("should return false with null", function() {
1474 expect(Ext.isTextNode(null)).toBe(false);
1477 it("should return false with undefined", function() {
1478 expect(Ext.isTextNode(undefined)).toBe(false);
1481 it("should return false with date", function() {
1482 expect(Ext.isTextNode(new Date())).toBe(false);
1485 it("should return false with empty object", function() {
1486 expect(Ext.isTextNode({})).toBe(false);
1489 it("should return false with node list", function() {
1490 expect(Ext.isTextNode(document.getElementsByTagName('body'))).toBe(false);
1493 it("should return false with element", function() {
1494 expect(Ext.isTextNode(Ext.getBody().dom)).toBe(false);
1497 it("should return false with Ext.Element", function() {
1498 expect(Ext.isTextNode(Ext.getBody())).toBe(false);
1501 it("should return true with TextNode", function() {
1502 var textNode = document.createTextNode('foobar');
1503 document.body.appendChild(textNode);
1504 expect(Ext.isTextNode(textNode)).toBe(true);
1505 document.body.removeChild(textNode);
1509 describe("Ext.clone", function() {
1512 afterEach(function() {
1516 it("should clone an array", function() {
1517 var array = [2,'5',[1,3,4]];
1518 clone = Ext.clone(array);
1519 expect(clone).toEqual(array);
1520 expect(clone).not.toBe(array);
1523 it("should clone an object", function() {
1530 clone = Ext.clone(object);
1531 expect(clone).toEqual(object);
1532 expect(clone).not.toBe(object);
1535 it("should clone a date", function(){
1536 var date = new Date();
1537 clone = Ext.clone(date);
1538 expect(clone).toEqual(date);
1539 expect(clone).not.toBe(date);
1542 it("should clone a dom node", function(){
1543 var node = document.createElement('DIV');
1544 document.body.appendChild(node);
1545 clone = Ext.clone(node);
1546 expect(clone.tagName).toEqual(clone.tagName);
1547 expect(clone.innerHTML).toEqual(clone.innerHTML);
1548 expect(clone).not.toBe(node);
1549 document.body.removeChild(node);
1553 describe('getUniqueGlobalNamespace', function() {
1554 it("should return an unique global namespace", function() {
1555 expect(Ext.getUniqueGlobalNamespace()).toBe("ExtBox1");