Upgrade to ExtJS 4.0.7 - Released 10/19/2011
[extjs.git] / src / core / test / unit / spec / Ext-more.js
index 38d508b..fe1bbd8 100644 (file)
@@ -1,4 +1,21 @@
+/*
+
+This file is part of Ext JS 4
+
+Copyright (c) 2011 Sencha Inc
+
+Contact:  http://www.sencha.com/contact
+
+GNU General Public License Usage
+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.
+
+If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
+
+*/
 describe("Ext-more", function() {
+    beforeEach(function() {
+        addGlobal("ExtBox1"); 
+    });
     describe("Ext.id", function(){
         var el;
         describe("if element passed as first argument is different of document or window", function() {
@@ -41,13 +58,13 @@ describe("Ext-more", function() {
     });
 
     describe("Ext.getBody", function() {
-        it("should return current document body as an Ext.core.Element", function() {
+        it("should return current document body as an Ext.Element", function() {
             expect(Ext.getBody()).toEqual(Ext.get(document.body)); 
         });
     });
 
     describe("Ext.getHead", function() {
-        it("should return current document head as an Ext.core.Element", function() {
+        it("should return current document head as an Ext.Element", function() {
             expect(Ext.getHead()).toEqual(Ext.get(document.getElementsByTagName("head")[0]));
         });
     });
@@ -57,24 +74,26 @@ describe("Ext-more", function() {
             expect(Ext.getDoc()).toEqual(Ext.get(document));
         });
     });
-
-    describe("Ext.getCmp", function() {
-        it("should return a component", function() {
-            var cmp = new Ext.Component({id: 'foobar'});
-            expect(Ext.getCmp('foobar')).toBe(cmp);
-            cmp.destroy();
+    if (Ext.Component) {
+        describe("Ext.getCmp", function() {
+            it("should return a component", function() {
+                var cmp = new Ext.Component({id: 'foobar'});
+                expect(Ext.getCmp('foobar')).toBe(cmp);
+                cmp.destroy();
+            });
         });
-    });
-
-    describe("Ext.getOrientation", function() {
-        it("should return the current orientation of the mobile device", function() {
-            if (window.innerHeight <= window.innerWidth) {
-                expect(Ext.getOrientation()).toEqual("landscape");
-            } else {
-                expect(Ext.getOrientation()).toEqual("portrait");
-            }
+    }
+    if (!Ext.isWindows && !Ext.isMac && !Ext.isLinux) {
+        describe("Ext.getOrientation", function() {
+            it("should return the current orientation of the mobile device", function() {
+                if (window.innerHeight <= window.innerWidth) {
+                    expect(Ext.getOrientation()).toEqual("landscape");
+                } else {
+                    expect(Ext.getOrientation()).toEqual("portrait");
+                }
+            });
         });
-    });
+    }
 
     describe("Ext.callback", function() {
         var cfn;
@@ -263,26 +282,31 @@ describe("Ext-more", function() {
                     html: 'foobar'
                 });
                 id = el.id;
-
             });
 
             it("should remove a dom element from document", function(){
                 Ext.removeNode(el.dom);
-                expect(document.body.childNodes[0]).toBeUndefined();
+               if (!Ext.isIE) {
+                    expect(el.dom.parentNode).toBe(null);
+               } else {
+                   expect(el.dom.parentNode.innerHTML).toBe(undefined);
+               }
             });
 
             it("should delete the cache reference", function() {
                 Ext.removeNode(el.dom);
                 expect(Ext.cache[id]).toBeUndefined();
             });
+            if (!Ext.isIE6 && !Ext.isIE7) {
+                it("should remove all listeners from the dom element", function() {
+                        var listener = jasmine.createSpy();
+                        el.on('mouseup', listener);
+                        Ext.removeNode(el.dom);
+                        jasmine.fireMouseEvent(el.dom, 'mouseup');
+                        expect(listener).not.toHaveBeenCalled();
 
-            it("should remove all listeners from the dom element", function() {
-                var listener = jasmine.createSpy();
-                el.on('mouseup', listener);
-                Ext.removeNode(el.dom);
-                jasmine.fireMouseEvent(el.dom, 'mouseup');
-                expect(listener).not.toHaveBeenCalled();
-            });
+                });
+            }
         });
 
         describe("if passed element is body", function() {
@@ -300,47 +324,51 @@ describe("Ext-more", function() {
                 Ext.getBody().un('mouseup', listener);
             });
         });
+        
+        if (!Ext.isIE6 && !Ext.isIE7) {
+            describe("if enableNestedListenerRemoval is true", function() {
+                var el, child;
+
+                beforeEach(function(){
+                    Ext.enableNestedListenerRemoval = true;
+                    el = Ext.getBody().createChild();
+                    child = el.createChild();
+                });
 
-        describe("if enableNestedListenerRemoval is true", function() {
-            var el, child;
-
-            beforeEach(function(){
-                Ext.enableNestedListenerRemoval = true;
-                el = Ext.getBody().createChild();
-                child = el.createChild();
-            });
-
-            afterEach(function(){
-                Ext.enableNestedListenerRemoval = false;
-            });
-
-            it("should remove listener on children", function() {
-                var listener = jasmine.createSpy();
-                child.on('mouseup', listener); 
-                Ext.removeNode(el.dom);
-                jasmine.fireMouseEvent(child.dom, 'mouseup');
-                expect(listener).not.toHaveBeenCalled();
-            });
+                afterEach(function(){
+                    Ext.enableNestedListenerRemoval = false;
+                });
 
-        });
+                    it("should remove listener on children", function() {
+                        var listener = jasmine.createSpy();
+                        child.on('mouseup', listener); 
+                        Ext.removeNode(el.dom);
+                        jasmine.fireMouseEvent(child.dom, 'mouseup');
+                        expect(listener).not.toHaveBeenCalled();
+                    });
 
-        describe("if enableNestedListenerRemoval is false (default)", function() {
-            var el, child;
 
-            beforeEach(function(){
-                el = Ext.getBody().createChild();
-                child = el.createChild();
             });
+        }
+        if (!Ext.isIE6 && !Ext.isIE7) {
+            describe("if enableNestedListenerRemoval is false (default)", function() {
+                var el, child;
+
+                beforeEach(function(){
+                    el = Ext.getBody().createChild();
+                    child = el.createChild();
+                });
 
-            it("should not remove listener on children", function() {
-                var listener = jasmine.createSpy();
-                child.on('mouseup', listener); 
-                Ext.removeNode(el.dom);
-                jasmine.fireMouseEvent(child.dom, 'mouseup');
-                expect(listener).toHaveBeenCalled();
-                Ext.EventManager.purgeElement(child.dom);
+                it("should not remove listener on children", function() {
+                    var listener = jasmine.createSpy();
+                    child.on('mouseup', listener); 
+                    Ext.removeNode(el.dom);
+                    jasmine.fireMouseEvent(child.dom, 'mouseup');
+                    expect(listener).toHaveBeenCalled();
+                    Ext.EventManager.purgeElement(child.dom);
+                });
             });
-        });
+        }
     });
 
     describe("Ext.addBehaviors", function() {
@@ -491,7 +519,7 @@ describe("Ext-more", function() {
                     'a'
                 ];
                  expect(Ext.partition(array, function(item){
-                        return item == "a"
+                        return item == "a";
                 })).toEqual([
                     ['a', 'a'], 
                     ['b', 'c']
@@ -529,7 +557,7 @@ describe("Ext-more", function() {
                 });                    
                 
                 expect(Ext.partition(Ext.query("p"), function(val){
-                        return val.className == "class1"
+                        return val.className == "class1";
                 })).toEqual([
                     [p[0].dom, p[2].dom, p[5].dom], 
                     [p[1].dom, p[3].dom, p[4].dom]
@@ -542,3 +570,4 @@ describe("Ext-more", function() {
         });
     });
 });
+