1 describe("Ext", function() {
3 describe("Ext.global", function() {
4 it("should return the global scope", function() {
5 expect(Ext.global).toBe((function(){ return this;}).call());
9 describe("Ext.apply", function() {
12 beforeEach(function() {
18 this.myMethodCalled = true;
20 toString: function() {
21 this.myToStringCalled = true;
26 it("should copy normal properties", function() {
30 otherThing: 'not cool',
34 expect(origin.name).toEqual('newName');
35 expect(origin.items).toEqual([4,5,6]);
36 expect(origin.something).toEqual('cool');
37 expect(origin.otherThing).toEqual('not cool');
38 expect(origin.isCool).toEqual(false);
41 it("should copy functions", function() {
44 this.newMethodCalled = true;
50 expect(origin.myMethodCalled).not.toBeDefined();
51 expect(origin.newMethodCalled).toBeTruthy();
54 it("should copy non-enumerables", function() {
56 toString: function() {
57 this.newToStringCalled = true;
63 expect(origin.myToStringCalled).not.toBeDefined();
64 expect(origin.newToStringCalled).toBeTruthy();
67 it("should apply properties and return an object", function() {
79 it("should change the reference of the object", function() {
92 it("should overwrite properties", function() {
108 it("should use default", function() {
126 it("should override all defaults", function() {
141 it("should return null if null is passed as first argument", function() {
142 expect(Ext.apply(null, {})).toBeNull();
145 it("should return the object if second argument is no defined", function() {
149 expect(Ext.apply(o)).toEqual(o);
152 it("should override valueOf", function() {
153 o = Ext.apply({}, {valueOf: 1});
155 expect(o.valueOf).toEqual(1);
158 it("should override toString", function() {
159 o = Ext.apply({}, {toString: 3});
161 expect(o.toString).toEqual(3);
166 describe("Ext.emptyFn", function() {
167 it("should return undefined without params", function() {
168 expect(Ext.emptyFn()).toBeUndefined();
171 it("should return undefined if you pass params", function() {
172 expect(Ext.emptyFn('aaaa', 'bbbbb')).toBeUndefined();
176 describe("Ext.iterate", function() {
179 beforeEach(function() {
180 itFn = jasmine.createSpy();
183 describe("iterate object", function() {
186 beforeEach(function() {
194 describe("if itFn does not return false", function() {
195 beforeEach(function() {
196 Ext.iterate(o, itFn);
199 it("should call the iterate function 3 times", function () {
200 expect(itFn.callCount).toEqual(3);
203 it("should call the iterate function with correct arguments", function () {
204 expect(itFn.calls[0].args).toEqual(["n1", 11, o]);
205 expect(itFn.calls[1].args).toEqual(["n2", 13, o]);
206 expect(itFn.calls[2].args).toEqual(["n3", 18, o]);
210 describe("if itFn return false", function() {
211 beforeEach(function() {
212 itFn.andReturn(false);
213 Ext.iterate(o, itFn);
216 it("should stop iteration if function return false", function() {
217 itFn.andReturn(false);
219 expect(itFn.calls.length).toEqual(1);
224 describe("do nothing on an empty object", function() {
227 beforeEach(function() {
229 Ext.iterate(o, itFn);
232 it("should not call the iterate function", function () {
233 expect(itFn).not.toHaveBeenCalled();
238 describe("iterate array", function() {
241 beforeEach(function() {
245 describe("if itFn does not return false", function() {
246 beforeEach(function() {
247 Ext.iterate(arr, itFn);
250 it("should call the iterate function 4 times", function () {
251 expect(itFn.callCount).toEqual(4);
254 it("should call the iterate function with correct arguments", function () {
255 expect(itFn.calls[0].args).toEqual([6, 0, arr]);
256 expect(itFn.calls[1].args).toEqual([7, 1, arr]);
257 expect(itFn.calls[2].args).toEqual([8, 2, arr]);
258 expect(itFn.calls[3].args).toEqual([9, 3, arr]);
262 describe("if itFn return false", function() {
263 beforeEach(function() {
264 itFn.andReturn(false);
265 Ext.iterate(arr, itFn);
268 it("should stop iteration if function return false", function() {
269 itFn.andReturn(false);
271 expect(itFn.calls.length).toEqual(1);
276 describe("do nothing on an empty array", function() {
279 beforeEach(function() {
281 Ext.iterate(arr, itFn);
284 it("should not call the iterate function", function () {
285 expect(itFn).not.toHaveBeenCalled();
291 describe("Ext.applyIf", function(){
294 it("should apply properties and return an object with an empty destination object", function() {
295 o = Ext.applyIf({}, {
306 it("should not override default properties", function() {
318 it("should not override default properties with mixing properties", function() {
334 it("should change the reference of the object", function() {
347 it("should return null if null is passed as first argument", function() {
348 expect(Ext.applyIf(null, {})).toBeNull();
351 it("should return the object if second argument is no defined", function() {
356 expect(Ext.applyIf(o)).toEqual(o);
361 describe("Ext.extend", function() {
362 var Dude, Awesome, david;
364 beforeEach(function() {
365 Dude = Ext.extend(Object, {
366 constructor: function(config){
367 Ext.apply(this, config);
368 this.isBadass = false;
372 Awesome = Ext.extend(Dude, {
373 constructor: function(){
374 Awesome.superclass.constructor.apply(this, arguments);
375 this.isBadass = true;
379 david = new Awesome({
384 it("should throw an error if superclass isn't defined", function() {
386 Ext.extend(undefined, {});
387 }).toRaiseExtError("Attempting to extend from a class which has not been loaded on the page.");
390 it("should create a superclass that return the original classe", function() {
391 expect(david.superclass).toEqual(Dude.prototype);
394 it("should add override method", function() {
395 expect(typeof david.override === 'function').toBe(true);
398 it("should override redefined methods", function() {
399 expect(david.isBadass).toBe(true);
402 it("should keep new properties", function() {
403 expect(david.davis).toEqual('isAwesome');
407 describe("Ext.override", function(){
411 beforeEach(function(){
412 Dude = function(){}; // avoid to directly override Object class
413 extApplySpy = spyOn(Ext, "apply");
416 it("should apply override", function(){
417 var override = {foo: true};
419 Ext.override(Dude, override);
421 expect(extApplySpy).toHaveBeenCalledWith(Dude.prototype, override);
425 describe("Ext.valueFrom", function() {
426 var value, defaultValue;
428 describe("with allowBlank", function() {
429 describe("and an empty string", function() {
430 it("should return the value", function() {
431 expect(Ext.valueFrom('', 'aaa', true)).toBe('');
435 describe("and a string", function() {
436 it("should return the value", function() {
437 expect(Ext.valueFrom('bbb', 'aaa', true)).toBe('bbb');
441 describe("and an undefined value", function() {
442 it("should return the default value", function() {
443 expect(Ext.valueFrom(undefined, 'aaa', true)).toBe('aaa');
447 describe("and a null value", function() {
448 it("should return the default value", function() {
449 expect(Ext.valueFrom(null, 'aaa', true)).toBe('aaa');
453 describe("and a 0 value", function() {
454 it("should return the value", function() {
455 expect(Ext.valueFrom(0, 'aaa', true)).toBe(0);
460 describe("without allowBlank", function() {
461 describe("and an empty string", function() {
462 it("should return the default value", function() {
463 expect(Ext.valueFrom('', 'aaa')).toBe('aaa');
467 describe("and a string", function() {
468 it("should return the value", function() {
469 expect(Ext.valueFrom('bbb', 'aaa')).toBe('bbb');
473 describe("and an undefined value", function() {
474 it("should return the default value", function() {
475 expect(Ext.valueFrom(undefined, 'aaa')).toBe('aaa');
479 describe("and a null value", function() {
480 it("should return the default value", function() {
481 expect(Ext.valueFrom(null, 'aaa')).toBe('aaa');
485 describe("and a 0 value", function() {
486 it("should return the value", function() {
487 expect(Ext.valueFrom(0, 'aaa')).toBe(0);
493 describe("Ext.typeOf", function() {
494 it("should return null", function() {
495 expect(Ext.typeOf(null)).toEqual('null');
497 it("should return undefined", function() {
498 expect(Ext.typeOf(undefined)).toEqual('undefined');
500 it("should return undefined", function() {
501 expect(Ext.typeOf(window.someWeirdPropertyThatDoesntExist)).toEqual('undefined');
503 it("should return string", function() {
504 expect(Ext.typeOf('')).toEqual('string');
506 it("should return string", function() {
507 expect(Ext.typeOf('something')).toEqual('string');
509 it("should return string", function() {
510 expect(Ext.typeOf('1.2')).toEqual('string');
512 it("should return number", function() {
513 expect(Ext.typeOf(1)).toEqual('number');
515 it("should return number", function() {
516 expect(Ext.typeOf(1.2)).toEqual('number');
518 it("should return boolean", function() {
519 expect(Ext.typeOf(true)).toEqual('boolean');
521 it("should return boolean", function() {
522 expect(Ext.typeOf(false)).toEqual('boolean');
524 it("should return array", function() {
525 expect(Ext.typeOf([1,2,3])).toEqual('array');
527 it("should return array", function() {
528 expect(Ext.typeOf(new Array(1,2,3))).toEqual('array');
530 it("should return function 1", function() {
531 expect(Ext.typeOf(function(){})).toEqual('function');
533 // Don't run this test in IE
534 if (typeof alert === 'function') {
535 it("should return function 2", function() {
536 expect(Ext.typeOf(prompt)).toEqual('function');
539 it("should return function 3", function() {
540 expect(Ext.typeOf(new Function())).toEqual('function');
542 it("should return regexp 1", function() {
543 expect(Ext.typeOf(/test/)).toEqual('regexp');
545 it("should return regexp 2", function() {
546 expect(Ext.typeOf(new RegExp('test'))).toEqual('regexp');
548 it("should return date", function() {
549 expect(Ext.typeOf(new Date())).toEqual('date');
551 it("should return textnode", function() {
552 expect(Ext.typeOf(document.createTextNode('tada'))).toEqual('textnode');
554 it("should return whitespace", function() {
555 expect(Ext.typeOf(document.createTextNode(' '))).toEqual('whitespace');
557 it("should return whitespace", function() {
558 expect(Ext.typeOf(document.createTextNode(' '))).toEqual('whitespace');
560 it("should return element", function() {
561 expect(Ext.typeOf(document.getElementsByTagName('body')[0])).toEqual('element');
563 it("should return element", function() {
564 expect(Ext.typeOf(document.createElement('button'))).toEqual('element');
566 it("should return element", function() {
567 expect(Ext.typeOf(new Image())).toEqual('element');
569 it("should return object 1", function() {
570 expect(Ext.typeOf({some: 'stuff'})).toEqual('object');
572 it("should return object 2", function() {
573 expect(Ext.typeOf(new Object())).toEqual('object');
575 it("should return object 3", function() {
576 expect(Ext.typeOf(window)).toEqual('object');
578 it("should return boolean", function() {
579 expect(Ext.typeOf(new Boolean(true))).toEqual('boolean');
581 it("should return number", function() {
582 expect(Ext.typeOf(new Number(1.2))).toEqual('number');
586 describe("Ext.isIterable", function() {
587 it("should return true with empty array", function() {
588 expect(Ext.isIterable([])).toBe(true);
591 it("should return true with filled array", function() {
592 expect(Ext.isIterable([1, 2, 3, 4])).toBe(true);
595 it("should return false with boolean true", function() {
596 expect(Ext.isIterable(true)).toBe(false);
599 it("should return false with boolean false", function() {
600 expect(Ext.isIterable(false)).toBe(false);
603 it("should return false with string", function() {
604 expect(Ext.isIterable("foo")).toBe(false);
607 it("should return false with empty string", function() {
608 expect(Ext.isIterable("")).toBe(false);
611 it("should return false with number", function() {
612 expect(Ext.isIterable(1)).toBe(false);
615 it("should return false with null", function() {
616 expect(Ext.isIterable(null)).toBe(false);
619 it("should return false with undefined", function() {
620 expect(Ext.isIterable(undefined)).toBe(false);
623 it("should return false with date", function() {
624 expect(Ext.isIterable(new Date())).toBe(false);
627 it("should return false with empty object", function() {
628 expect(Ext.isIterable({})).toBe(false);
631 it("should return true with node list", function() {
632 expect(Ext.isIterable(document.getElementsByTagName('body'))).toBe(true);
635 it("should return true with html collection", function() {
636 expect(Ext.isIterable(document.images)).toBe(true);
640 describe("Ext.isArray", function() {
641 it("should return true with empty array", function() {
642 expect(Ext.isArray([])).toBe(true);
645 it("should return true with filled array", function() {
646 expect(Ext.isArray([1, 2, 3, 4])).toBe(true);
649 it("should return false with boolean true", function() {
650 expect(Ext.isArray(true)).toBe(false);
653 it("should return false with boolean false", function() {
654 expect(Ext.isArray(false)).toBe(false);
657 it("should return false with string", function() {
658 expect(Ext.isArray("foo")).toBe(false);
661 it("should return false with empty string", function() {
662 expect(Ext.isArray("")).toBe(false);
665 it("should return false with number", function() {
666 expect(Ext.isArray(1)).toBe(false);
669 it("should return false with null", function() {
670 expect(Ext.isArray(null)).toBe(false);
673 it("should return false with undefined", function() {
674 expect(Ext.isArray(undefined)).toBe(false);
677 it("should return false with date", function() {
678 expect(Ext.isArray(new Date())).toBe(false);
681 it("should return false with empty object", function() {
682 expect(Ext.isArray({})).toBe(false);
685 it("should return false with node list", function() {
686 expect(Ext.isArray(document.getElementsByTagName('body'))).toBe(false);
689 it("should return false with custom class that has a length property", function() {
690 var C = Ext.extend(Object, {
693 expect(Ext.isArray(new C())).toBe(false);
696 it("should return false with element", function() {
697 expect(Ext.isArray(Ext.getBody().dom)).toBe(false);
701 describe("Ext.isBoolean", function() {
702 it("should return false with empty array", function() {
703 expect(Ext.isBoolean([])).toBe(false);
706 it("should return false with filled array", function() {
707 expect(Ext.isBoolean([1, 2, 3, 4])).toBe(false);
710 it("should return true with boolean true", function() {
711 expect(Ext.isBoolean(true)).toBe(true);
714 it("should return true with boolean false", function() {
715 expect(Ext.isBoolean(false)).toBe(true);
718 it("should return false with string", function() {
719 expect(Ext.isBoolean("foo")).toBe(false);
722 it("should return false with empty string", function() {
723 expect(Ext.isBoolean("")).toBe(false);
726 it("should return false with number", function() {
727 expect(Ext.isBoolean(1)).toBe(false);
730 it("should return false with null", function() {
731 expect(Ext.isBoolean(null)).toBe(false);
734 it("should return false with undefined", function() {
735 expect(Ext.isBoolean(undefined)).toBe(false);
738 it("should return false with date", function() {
739 expect(Ext.isBoolean(new Date())).toBe(false);
742 it("should return false with empty object", function() {
743 expect(Ext.isBoolean({})).toBe(false);
746 it("should return false with node list", function() {
747 expect(Ext.isBoolean(document.getElementsByTagName('body'))).toBe(false);
750 it("should return false with element", function() {
751 expect(Ext.isArray(Ext.getBody().dom)).toBe(false);
755 describe("Ext.isDate", function() {
756 it("should return false with empty array", function() {
757 expect(Ext.isDate([])).toBe(false);
760 it("should return false with filled array", function() {
761 expect(Ext.isDate([1, 2, 3, 4])).toBe(false);
764 it("should return false with boolean true", function() {
765 expect(Ext.isDate(true)).toBe(false);
768 it("should return false with boolean false", function() {
769 expect(Ext.isDate(false)).toBe(false);
772 it("should return false with string", function() {
773 expect(Ext.isDate("foo")).toBe(false);
776 it("should return false with empty string", function() {
777 expect(Ext.isDate("")).toBe(false);
780 it("should return false with number", function() {
781 expect(Ext.isDate(1)).toBe(false);
784 it("should return false with null", function() {
785 expect(Ext.isDate(null)).toBe(false);
788 it("should return false with undefined", function() {
789 expect(Ext.isDate(undefined)).toBe(false);
792 it("should return true with date", function() {
793 expect(Ext.isDate(new Date())).toBe(true);
796 it("should return false with empty object", function() {
797 expect(Ext.isDate({})).toBe(false);
800 it("should return false with node list", function() {
801 expect(Ext.isDate(document.getElementsByTagName('body'))).toBe(false);
804 it("should return false with element", function() {
805 expect(Ext.isDate(Ext.getBody().dom)).toBe(false);
809 describe("Ext.isDefined", function() {
810 it("should return true with empty array", function() {
811 expect(Ext.isDefined([])).toBe(true);
814 it("should return true with filled array", function() {
815 expect(Ext.isDefined([1, 2, 3, 4])).toBe(true);
818 it("should return true with boolean true", function() {
819 expect(Ext.isDefined(true)).toBe(true);
822 it("should return true with boolean false", function() {
823 expect(Ext.isDefined(false)).toBe(true);
826 it("should return true with string", function() {
827 expect(Ext.isDefined("foo")).toBe(true);
830 it("should return true with empty string", function() {
831 expect(Ext.isDefined("")).toBe(true);
834 it("should return true with number", function() {
835 expect(Ext.isDefined(1)).toBe(true);
838 it("should return true with null", function() {
839 expect(Ext.isDefined(null)).toBe(true);
842 it("should return false with undefined", function() {
843 expect(Ext.isDefined(undefined)).toBe(false);
846 it("should return true with date", function() {
847 expect(Ext.isDefined(new Date())).toBe(true);
850 it("should return true with empty object", function() {
851 expect(Ext.isDefined({})).toBe(true);
854 it("should return true with node list", function() {
855 expect(Ext.isDefined(document.getElementsByTagName('body'))).toBe(true);
858 it("should return true with element", function() {
859 expect(Ext.isDefined(Ext.getBody().dom)).toBe(true);
863 describe("Ext.isElement", function() {
864 it("should return false with empty array", function() {
865 expect(Ext.isElement([])).toBe(false);
868 it("should return false with filled array", function() {
869 expect(Ext.isElement([1, 2, 3, 4])).toBe(false);
872 it("should return false with boolean true", function() {
873 expect(Ext.isElement(true)).toBe(false);
876 it("should return false with boolean false", function() {
877 expect(Ext.isElement(false)).toBe(false);
880 it("should return false with string", function() {
881 expect(Ext.isElement("foo")).toBe(false);
884 it("should return false with empty string", function() {
885 expect(Ext.isElement("")).toBe(false);
888 it("should return false with number", function() {
889 expect(Ext.isElement(1)).toBe(false);
892 it("should return false with null", function() {
893 expect(Ext.isElement(null)).toBe(false);
896 it("should return false with undefined", function() {
897 expect(Ext.isElement(undefined)).toBe(false);
900 it("should return false with date", function() {
901 expect(Ext.isElement(new Date())).toBe(false);
904 it("should return false with empty object", function() {
905 expect(Ext.isElement({})).toBe(false);
908 it("should return false with node list", function() {
909 expect(Ext.isElement(document.getElementsByTagName('body'))).toBe(false);
912 it("should return true with element", function() {
913 expect(Ext.isElement(Ext.getBody().dom)).toBe(true);
916 it("should return false with Ext.core.Element", function() {
917 expect(Ext.isElement(Ext.getBody())).toBe(false);
920 it("should return false with TextNode", function() {
921 var textNode = document.createTextNode('foobar');
922 document.body.appendChild(textNode);
923 expect(Ext.isElement(textNode)).toBe(false);
924 document.body.removeChild(textNode);
928 describe("Ext.isEmpty", function() {
929 it("should return true with empty array", function() {
930 expect(Ext.isEmpty([])).toBe(true);
933 it("should return false with filled array", function() {
934 expect(Ext.isEmpty([1, 2, 3, 4])).toBe(false);
937 it("should return false with boolean true", function() {
938 expect(Ext.isEmpty(true)).toBe(false);
941 it("should return false with boolean false", function() {
942 expect(Ext.isEmpty(false)).toBe(false);
945 it("should return false with string", function() {
946 expect(Ext.isEmpty("foo")).toBe(false);
949 it("should return true with empty string", function() {
950 expect(Ext.isEmpty("")).toBe(true);
953 it("should return true with empty string with allowBlank", function() {
954 expect(Ext.isEmpty("", true)).toBe(false);
957 it("should return false with number", function() {
958 expect(Ext.isEmpty(1)).toBe(false);
961 it("should return true with null", function() {
962 expect(Ext.isEmpty(null)).toBe(true);
965 it("should return true with undefined", function() {
966 expect(Ext.isEmpty(undefined)).toBe(true);
969 it("should return false with date", function() {
970 expect(Ext.isEmpty(new Date())).toBe(false);
973 it("should return false with empty object", function() {
974 expect(Ext.isEmpty({})).toBe(false);
978 describe("Ext.isFunction", function() {
979 beforeEach(function() {
980 // add global variable in whitelist
981 addGlobal("ExtSandbox1");
984 it("should return true with anonymous function", function() {
985 expect(Ext.isFunction(function(){})).toBe(true);
988 it("should return true with new Function syntax", function() {
989 expect(Ext.isFunction(Ext.functionFactory('return "";'))).toBe(true);
992 it("should return true with static function", function() {
993 expect(Ext.isFunction(Ext.emptyFn)).toBe(true);
996 it("should return true with instance function", function() {
997 var stupidClass = function() {},
999 stupidClass.prototype.testMe = function() {};
1000 testObject = new stupidClass();
1002 expect(Ext.isFunction(testObject.testMe)).toBe(true);
1005 it("should return true with function on object", function() {
1011 expect(Ext.isFunction(o.fn)).toBe(true);
1014 it("should return false with empty array", function() {
1015 expect(Ext.isFunction([])).toBe(false);
1018 it("should return false with filled array", function() {
1019 expect(Ext.isFunction([1, 2, 3, 4])).toBe(false);
1022 it("should return false with boolean true", function() {
1023 expect(Ext.isFunction(true)).toBe(false);
1026 it("should return false with boolean false", function() {
1027 expect(Ext.isFunction(false)).toBe(false);
1030 it("should return false with string", function() {
1031 expect(Ext.isFunction("foo")).toBe(false);
1034 it("should return false with empty string", function() {
1035 expect(Ext.isFunction("")).toBe(false);
1038 it("should return false with number", function() {
1039 expect(Ext.isFunction(1)).toBe(false);
1042 it("should return false with null", function() {
1043 expect(Ext.isFunction(null)).toBe(false);
1046 it("should return false with undefined", function() {
1047 expect(Ext.isFunction(undefined)).toBe(false);
1050 it("should return false with date", function() {
1051 expect(Ext.isFunction(new Date())).toBe(false);
1054 it("should return false with empty object", function() {
1055 expect(Ext.isFunction({})).toBe(false);
1058 it("should return false with node list", function() {
1059 expect(Ext.isFunction(document.getElementsByTagName('body'))).toBe(false);
1063 describe("Ext.isNumber", function() {
1064 it("should return true with zero", function() {
1065 expect(Ext.isNumber(0)).toBe(true);
1068 it("should return true with non zero", function() {
1069 expect(Ext.isNumber(4)).toBe(true);
1072 it("should return true with negative integer", function() {
1073 expect(Ext.isNumber(-3)).toBe(true);
1076 it("should return true with float", function() {
1077 expect(Ext.isNumber(1.75)).toBe(true);
1080 it("should return true with negative float", function() {
1081 expect(Ext.isNumber(-4.75)).toBe(true);
1084 it("should return true with Number.MAX_VALUE", function() {
1085 expect(Ext.isNumber(Number.MAX_VALUE)).toBe(true);
1088 it("should return true with Number.MIN_VALUE", function() {
1089 expect(Ext.isNumber(Number.MIN_VALUE)).toBe(true);
1092 it("should return true with Math.PI", function() {
1093 expect(Ext.isNumber(Math.PI)).toBe(true);
1096 it("should return true with Number() contructor", function() {
1097 expect(Ext.isNumber(Number('3.1'))).toBe(true);
1100 it("should return false with NaN", function() {
1101 expect(Ext.isNumber(Number.NaN)).toBe(false);
1104 it("should return false with Number.POSITIVE_INFINITY", function() {
1105 expect(Ext.isNumber(Number.POSITIVE_INFINITY)).toBe(false);
1108 it("should return false with Number.NEGATIVE_INFINITY", function() {
1109 expect(Ext.isNumber(Number.NEGATIVE_INFINITY)).toBe(false);
1112 it("should return false with empty array", function() {
1113 expect(Ext.isNumber([])).toBe(false);
1116 it("should return false with filled array", function() {
1117 expect(Ext.isNumber([1, 2, 3, 4])).toBe(false);
1120 it("should return false with boolean true", function() {
1121 expect(Ext.isNumber(true)).toBe(false);
1124 it("should return false with boolean false", function() {
1125 expect(Ext.isNumber(false)).toBe(false);
1128 it("should return false with string", function() {
1129 expect(Ext.isNumber("foo")).toBe(false);
1132 it("should return false with empty string", function() {
1133 expect(Ext.isNumber("")).toBe(false);
1136 it("should return false with string containing a number", function() {
1137 expect(Ext.isNumber("1.0")).toBe(false);
1140 it("should return false with undefined", function() {
1141 expect(Ext.isNumber(undefined)).toBe(false);
1144 it("should return false with date", function() {
1145 expect(Ext.isNumber(new Date())).toBe(false);
1148 it("should return false with empty object", function() {
1149 expect(Ext.isNumber({})).toBe(false);
1152 it("should return false with node list", function() {
1153 expect(Ext.isNumber(document.getElementsByTagName('body'))).toBe(false);
1157 describe("Ext.isNumeric", function() {
1158 it("should return true with zero", function() {
1159 expect(Ext.isNumeric(0)).toBe(true);
1162 it("should return true with non zero", function() {
1163 expect(Ext.isNumeric(4)).toBe(true);
1166 it("should return true with negative integer", function() {
1167 expect(Ext.isNumeric(-3)).toBe(true);
1170 it("should return true with float", function() {
1171 expect(Ext.isNumeric(1.75)).toBe(true);
1174 it("should return true with negative float", function() {
1175 expect(Ext.isNumeric(-4.75)).toBe(true);
1178 it("should return true with Number.MAX_VALUE", function() {
1179 expect(Ext.isNumeric(Number.MAX_VALUE)).toBe(true);
1182 it("should return true with Number.MIN_VALUE", function() {
1183 expect(Ext.isNumeric(Number.MIN_VALUE)).toBe(true);
1186 it("should return true with Math.PI", function() {
1187 expect(Ext.isNumeric(Math.PI)).toBe(true);
1190 it("should return true with Number() contructor", function() {
1191 expect(Ext.isNumeric(Number('3.1'))).toBe(true);
1194 it("should return false with NaN", function() {
1195 expect(Ext.isNumeric(Number.NaN)).toBe(false);
1198 it("should return false with Number.POSITIVE_INFINITY", function() {
1199 expect(Ext.isNumeric(Number.POSITIVE_INFINITY)).toBe(false);
1202 it("should return false with Number.NEGATIVE_INFINITY", function() {
1203 expect(Ext.isNumeric(Number.NEGATIVE_INFINITY)).toBe(false);
1206 it("should return false with empty array", function() {
1207 expect(Ext.isNumeric([])).toBe(false);
1210 it("should return false with filled array", function() {
1211 expect(Ext.isNumeric([1, 2, 3, 4])).toBe(false);
1214 it("should return false with boolean true", function() {
1215 expect(Ext.isNumeric(true)).toBe(false);
1218 it("should return false with boolean false", function() {
1219 expect(Ext.isNumeric(false)).toBe(false);
1222 it("should return false with string", function() {
1223 expect(Ext.isNumeric("foo")).toBe(false);
1226 it("should return false with empty string", function() {
1227 expect(Ext.isNumeric("")).toBe(false);
1230 it("should return true with string containing a number", function() {
1231 expect(Ext.isNumeric("1.0")).toBe(true);
1234 it("should return false with undefined", function() {
1235 expect(Ext.isNumeric(undefined)).toBe(false);
1238 it("should return false with date", function() {
1239 expect(Ext.isNumeric(new Date())).toBe(false);
1242 it("should return false with empty object", function() {
1243 expect(Ext.isNumeric({})).toBe(false);
1246 it("should return false with node list", function() {
1247 expect(Ext.isNumeric(document.getElementsByTagName('body'))).toBe(false);
1251 describe("Ext.isObject", function() {
1252 it("should return false with empty array", function() {
1253 expect(Ext.isObject([])).toBe(false);
1256 it("should return false with filled array", function() {
1257 expect(Ext.isObject([1, 2, 3, 4])).toBe(false);
1260 it("should return false with boolean true", function() {
1261 expect(Ext.isObject(true)).toBe(false);
1264 it("should return false with boolean false", function() {
1265 expect(Ext.isObject(false)).toBe(false);
1268 it("should return false with string", function() {
1269 expect(Ext.isObject("foo")).toBe(false);
1272 it("should return false with empty string", function() {
1273 expect(Ext.isObject("")).toBe(false);
1276 it("should return false with number", function() {
1277 expect(Ext.isObject(1)).toBe(false);
1280 it("should return false with null", function() {
1281 expect(Ext.isObject(null)).toBe(false);
1284 it("should return false with undefined", function() {
1285 expect(Ext.isObject(undefined)).toBe(false);
1288 it("should return false with date", function() {
1289 expect(Ext.isObject(new Date())).toBe(false);
1292 it("should return true with empty object", function() {
1293 expect(Ext.isObject({})).toBe(true);
1296 it("should return false with a DOM node", function() {
1297 expect(Ext.isObject(document.body)).toBe(false);
1300 it("should return false with a Text node", function() {
1301 expect(Ext.isObject(document.createTextNode('test'))).toBe(false);
1304 it("should return true with object with properties", function() {
1305 expect(Ext.isObject({
1310 it("should return true with object instance", function() {
1311 var stupidClass = function() {};
1313 expect(Ext.isObject(new stupidClass())).toBe(true);
1316 it("should return true with new Object syntax", function() {
1317 expect(Ext.isObject(new Object())).toBe(true);
1320 it("should return false with dom element", function() {
1321 expect(Ext.isObject(document.body)).toBe(false);
1325 describe("Ext.isPrimitive", function() {
1326 it("should return true with integer", function() {
1327 expect(Ext.isPrimitive(1)).toBe(true);
1330 it("should return true with negative integer", function() {
1331 expect(Ext.isPrimitive(-21)).toBe(true);
1334 it("should return true with float", function() {
1335 expect(Ext.isPrimitive(2.1)).toBe(true);
1338 it("should return true with negative float", function() {
1339 expect(Ext.isPrimitive(-12.1)).toBe(true);
1342 it("should return true with Number.MAX_VALUE", function() {
1343 expect(Ext.isPrimitive(Number.MAX_VALUE)).toBe(true);
1346 it("should return true with Math.PI", function() {
1347 expect(Ext.isPrimitive(Math.PI)).toBe(true);
1350 it("should return true with empty string", function() {
1351 expect(Ext.isPrimitive("")).toBe(true);
1354 it("should return true with non empty string", function() {
1355 expect(Ext.isPrimitive("foo")).toBe(true);
1358 it("should return true with boolean true", function() {
1359 expect(Ext.isPrimitive(true)).toBe(true);
1362 it("should return true with boolean false", function() {
1363 expect(Ext.isPrimitive(false)).toBe(true);
1366 it("should return false with null", function() {
1367 expect(Ext.isPrimitive(null)).toBe(false);
1370 it("should return false with undefined", function() {
1371 expect(Ext.isPrimitive(undefined)).toBe(false);
1374 it("should return false with object", function() {
1375 expect(Ext.isPrimitive({})).toBe(false);
1378 it("should return false with object instance", function() {
1379 var stupidClass = function() {};
1380 expect(Ext.isPrimitive(new stupidClass())).toBe(false);
1383 it("should return false with array", function() {
1384 expect(Ext.isPrimitive([])).toBe(false);
1388 describe("Ext.isString", function() {
1389 it("should return true with empty string", function() {
1390 expect(Ext.isString("")).toBe(true);
1393 it("should return true with non empty string", function() {
1394 expect(Ext.isString("foo")).toBe(true);
1397 it("should return true with String() syntax", function() {
1398 expect(Ext.isString(String(""))).toBe(true);
1401 it("should return false with new String() syntax", function() { //should return an object that wraps the primitive
1402 expect(Ext.isString(new String(""))).toBe(false);
1405 it("should return false with number", function() {
1406 expect(Ext.isString(1)).toBe(false);
1409 it("should return false with boolean", function() {
1410 expect(Ext.isString(true)).toBe(false);
1413 it("should return false with null", function() {
1414 expect(Ext.isString(null)).toBe(false);
1417 it("should return false with undefined", function() {
1418 expect(Ext.isString(undefined)).toBe(false);
1421 it("should return false with array", function() {
1422 expect(Ext.isString([])).toBe(false);
1425 it("should return false with object", function() {
1426 expect(Ext.isString({})).toBe(false);
1430 describe("Ext.isTextNode", function() {
1431 it("should return false with empty array", function() {
1432 expect(Ext.isTextNode([])).toBe(false);
1435 it("should return false with filled array", function() {
1436 expect(Ext.isTextNode([1, 2, 3, 4])).toBe(false);
1439 it("should return false with boolean true", function() {
1440 expect(Ext.isTextNode(true)).toBe(false);
1443 it("should return false with boolean false", function() {
1444 expect(Ext.isTextNode(false)).toBe(false);
1447 it("should return false with string", function() {
1448 expect(Ext.isTextNode("foo")).toBe(false);
1451 it("should return false with empty string", function() {
1452 expect(Ext.isTextNode("")).toBe(false);
1455 it("should return false with number", function() {
1456 expect(Ext.isTextNode(1)).toBe(false);
1459 it("should return false with null", function() {
1460 expect(Ext.isTextNode(null)).toBe(false);
1463 it("should return false with undefined", function() {
1464 expect(Ext.isTextNode(undefined)).toBe(false);
1467 it("should return false with date", function() {
1468 expect(Ext.isTextNode(new Date())).toBe(false);
1471 it("should return false with empty object", function() {
1472 expect(Ext.isTextNode({})).toBe(false);
1475 it("should return false with node list", function() {
1476 expect(Ext.isTextNode(document.getElementsByTagName('body'))).toBe(false);
1479 it("should return false with element", function() {
1480 expect(Ext.isTextNode(Ext.getBody().dom)).toBe(false);
1483 it("should return false with Ext.core.Element", function() {
1484 expect(Ext.isTextNode(Ext.getBody())).toBe(false);
1487 it("should return true with TextNode", function() {
1488 var textNode = document.createTextNode('foobar');
1489 document.body.appendChild(textNode);
1490 expect(Ext.isTextNode(textNode)).toBe(true);
1491 document.body.removeChild(textNode);
1495 describe("Ext.clone", function() {
1498 afterEach(function() {
1502 it("should clone an array", function() {
1503 var array = [2,'5',[1,3,4]];
1504 clone = Ext.clone(array);
1505 expect(clone).toEqual(array);
1506 expect(clone).not.toBe(array);
1509 it("should clone an object", function() {
1516 clone = Ext.clone(object);
1517 expect(clone).toEqual(object);
1518 expect(clone).not.toBe(object);
1521 it("should clone a date", function(){
1522 var date = new Date();
1523 clone = Ext.clone(date);
1524 expect(clone).toEqual(date);
1525 expect(clone).not.toBe(date);
1528 it("should clone a dom node", function(){
1529 var node = document.createElement('DIV');
1530 document.body.appendChild(node);
1531 clone = Ext.clone(node);
1532 expect(clone.tagName).toEqual(clone.tagName);
1533 expect(clone.innerHTML).toEqual(clone.innerHTML);
1534 expect(clone).not.toBe(node);
1535 document.body.removeChild(node);
1539 describe('getUniqueGlobalNamespace', function() {
1540 it("should return an unique global namespace", function() {
1541 expect(Ext.getUniqueGlobalNamespace()).toBe("ExtSandbox1");