Upgrade to ExtJS 4.0.1 - Released 05/18/2011
[extjs.git] / src / core / test / unit / spec / Ext-mess.backup
index 42ad96e..5035e26 100644 (file)
@@ -1,40 +1,5 @@
 describe("Ext-mess", function() {
-    describe("Ext.id", function(){
-        var el;
-        describe("if element passed as first argument is different of document or window", function() {
-            beforeEach(function() {
-                el = document.createElement("div"); // do not use the Ext.getBody().createChild() method because it call Ext.id
-                Ext.getBody().appendChild(el);
-            });
-
-            it("should generate an unique id for the element with default prefix ext-gen", function() {
-                expect(Ext.id(el)).toEqual("ext-gen" + Ext.idSeed);
-            });
-
-            it("should generate an unique id for the element with custom prefix", function() {
-                var prefix = "nico-yhwh";
-                expect(Ext.id(el, prefix)).toEqual(prefix + Ext.idSeed);
-            });
-
-            it("should not override existing id", function() {
-                var id = "unchanged";
-                el.id = id;
-                expect(Ext.id(el)).toEqual(id);
-            });
-        });
-
-        describe("if element passed as first argument is document", function() {
-            it("should return Ext.documentId", function() {
-                expect(Ext.id(document)).toEqual(Ext.documentId);
-            });
-        });
-
-        describe("if element passed as first argument is window", function() {
-            it("should return Ext.windowId", function() {
-                expect(Ext.id(window)).toEqual(Ext.windowId);
-            });
-        });
-    });
+   
 
     xdescribe("Ext.repaint", function() {
         it("should create a mask in the body", function(){
@@ -50,372 +15,9 @@ describe("Ext-mess", function() {
         });
     });
 
-    describe("Ext.destroy", function() {
-        var o1, o2, o3;
-
-        beforeEach(function() {
-            o1 = jasmine.createSpyObj("o1", ["destroy"]);
-
-            o2 = jasmine.createSpyObj("o2", ["destroy"]);
-
-            o3 = jasmine.createSpyObj("o3", ["dest"]);
-
-        });
-
-        it("should destroy an object", function() {
-            Ext.destroy(o1);
-
-            expect(o1.destroy).toHaveBeenCalled();
-        });
-
-        it("should no destroy an object without a destroy method", function() {
-            Ext.destroy(o3);
-
-            expect(o3.dest).not.toHaveBeenCalled();
-        });
-
-        it("should destroy an array of objects", function() {
-            Ext.destroy([o1, o2, o3]);
-
-            expect(o1.destroy).toHaveBeenCalled();
-            expect(o2.destroy).toHaveBeenCalled();
-            expect(o3.dest).not.toHaveBeenCalled();
-        });
-
-        it("should destroy multiple objects", function() {
-            Ext.destroy(o1, o2, o3);
-
-            expect(o1.destroy).toHaveBeenCalled();
-            expect(o2.destroy).toHaveBeenCalled();
-            expect(o3.dest).not.toHaveBeenCalled();
-        });
-
-        it("should remove dom if object is an Ext.element", function() {
-           var el = Ext.getBody().createChild({id: "to_destroy"});
-
-           Ext.destroy(el);
-
-           expect(Ext.fly("to_destroy")).toBeNull();
-        });
-    });
-
-    describe("Ext.each", function() {
-         var itFn;
-
-        beforeEach(function() {
-            itFn = jasmine.createSpy("on itFn");
-        });
-
-        describe("each object", function() {
-            var o;
-
-            beforeEach(function() {
-                o = {
-                    n1: 11,
-                    n2: 13,
-                    n3: 18
-                };
-            });
-
-            describe("if itFn does not return false", function() {
-                beforeEach(function() {
-                    Ext.each(o, itFn);
-                });
-
-                it("should call the each function 3 times", function () {
-                    expect(itFn.callCount).toEqual(3);
-                });
-
-                it("should call the each function with correct arguments", function () {
-                    expect(itFn.calls[0].args).toEqual(["n1", 11, o]);
-                    expect(itFn.calls[1].args).toEqual(["n2", 13, o]);
-                    expect(itFn.calls[2].args).toEqual(["n3", 18, o]);
-                });
-            });
-
-            describe("if itFn return false", function() {
-                beforeEach(function() {
-                    itFn.andReturn(false);
-                    Ext.each(o, itFn);
-                });
-
-                it("should stop iteration if function return false", function() {
-                    itFn.andReturn(false);
-
-                    expect(itFn.calls.length).toEqual(1);
-                });
-            });
-        });
-
-        describe("do nothing on an empty object", function() {
-            var o;
-
-            beforeEach(function() {
-                o = {};
-                Ext.each(o, itFn);
-            });
-
-            it("should not call the each function", function () {
-                expect(itFn).not.toHaveBeenCalled();
-            });
-
-        });
-
-        describe("each array", function() {
-            var arr;
-
-            beforeEach(function() {
-                arr = [6, 7, 8, 9];
-            });
-
-            describe("if itFn does not return false", function() {
-                beforeEach(function() {
-                    Ext.each(arr, itFn);
-                });
-
-                it("should call the each function 4 times", function () {
-                    expect(itFn.callCount).toEqual(4);
-                });
-
-                it("should call the each function with correct arguments", function () {
-                    expect(itFn.calls[0].args).toEqual([6, 0, arr]);
-                    expect(itFn.calls[1].args).toEqual([7, 1, arr]);
-                    expect(itFn.calls[2].args).toEqual([8, 2, arr]);
-                    expect(itFn.calls[3].args).toEqual([9, 3, arr]);
-                });
-             });
-
-            describe("if itFn return false", function() {
-                beforeEach(function() {
-                    itFn.andReturn(false);
-                    Ext.each(arr, itFn);
-                });
-
-                it("should stop iteration if function return false", function() {
-                    itFn.andReturn(false);
-
-                    expect(itFn.calls.length).toEqual(1);
-                });
-            });
-        });
-
-        describe("do nothing on an empty array", function() {
-            var arr;
-
-            beforeEach(function() {
-                arr = [];
-                Ext.each(arr, itFn);
-            });
-
-            it("should not call the each function", function () {
-                expect(itFn).not.toHaveBeenCalled();
-            });
-
-        });
-
-        describe("simple cases", function() {
-            it("should work with an array of numbers", function() {
-                var sum = 0;
-
-                Ext.each([1, 2, 3, 4], function(val){
-                    sum += val;
-                });
-
-                expect(sum).toEqual(10);
-            });
-
-            it("should work with an array of strings", function() {
-                var str = '';
-
-                Ext.each(["S", "e", "n", "c", "h", "a"], function(s){
-                    str += s;
-                });
-
-                expect(str).toEqual("Sencha");
-            });
-
-            it("should pass index correctly", function() {
-                var arr = [];
-                Ext.each([1, 2, 3, 4, 5, 6], function(val, idx){
-                    arr.push(idx);
-                });
-                expect(arr).toEqual([0, 1, 2, 3, 4, 5]);
-            });
-
-            it("should work with a non array parameter", function() {
-                var sum = 0;
-
-                Ext.each(5, function(num){
-                    sum += num;
-                });
-
-                expect(sum).toEqual(5);
-            });
-        });
-
-        describe("more complex cases that need a spy", function() {
-            var eachFn;
-
-            beforeEach(function() {
-                eachFn = jasmine.createSpy();
-            });
-
-            it("should not run eachFn with an empty array", function() {
-                Ext.each([], eachFn);
-
-                expect(eachFn).not.toHaveBeenCalled();
-            });
-
-            it("should not run eachFn with null as first param", function() {
-                Ext.each(null, eachFn);
-
-                expect(eachFn).not.toHaveBeenCalled();
-            });
-
-            it("should iterate over NodeLists", function() {
-                Ext.each(document.getElementsByTagName('body'), eachFn);
-
-                expect(eachFn).toHaveBeenCalled();
-            });
-
-            it("should stop when function called with each item return false", function() {
-                eachFn.andCallFake(function(v) {
-                    if (v === 5) {
-                        return false;
-                    }
-                });
-
-                Ext.each([1, 2, 3, 4, 5, 6], eachFn);
-
-                expect(eachFn.callCount).toEqual(5);
-            });
-
-            it("should runfunction called with each item with correct scope", function() {
-
-                Ext.each([1, 2], eachFn, fakeScope);
-
-                expect(eachFn.calls[0].object).toBe(fakeScope);
-                expect(eachFn.calls[1].object).toBe(fakeScope);
-            });
-        });
-
-
-    });
-
-    describe("Ext.iterate", function() {
-        var itFn;
-
-        beforeEach(function() {
-            itFn = jasmine.createSpy();
-        });
-
-        describe("iterate object", function() {
-            var o;
-
-            beforeEach(function() {
-                o = {
-                    n1: 11,
-                    n2: 13,
-                    n3: 18
-                };
-            });
-
-            describe("if itFn does not return false", function() {
-                beforeEach(function() {
-                    Ext.iterate(o, itFn);
-                });
-
-                it("should call the iterate function 3 times", function () {
-                    expect(itFn.callCount).toEqual(3);
-                });
-
-                it("should call the iterate function with correct arguments", function () {
-                    expect(itFn.calls[0].args).toEqual(["n1", 11, o]);
-                    expect(itFn.calls[1].args).toEqual(["n2", 13, o]);
-                    expect(itFn.calls[2].args).toEqual(["n3", 18, o]);
-                });
-            });
 
-            describe("if itFn return false", function() {
-                beforeEach(function() {
-                    itFn.andReturn(false);
-                    Ext.iterate(o, itFn);
-                });
 
-                it("should stop iteration if function return false", function() {
-                    itFn.andReturn(false);
 
-                    expect(itFn.calls.length).toEqual(1);
-                });
-            });
-        });
-
-        describe("do nothing on an empty object", function() {
-            var o;
-
-            beforeEach(function() {
-                o = {};
-                Ext.iterate(o, itFn);
-            });
-
-            it("should not call the iterate function", function () {
-                expect(itFn).not.toHaveBeenCalled();
-            });
-
-        });
-
-        describe("iterate array", function() {
-            var arr;
-
-            beforeEach(function() {
-                arr = [6, 7, 8, 9];
-            });
-
-            describe("if itFn does not return false", function() {
-                beforeEach(function() {
-                    Ext.iterate(arr, itFn);
-                });
-
-                it("should call the iterate function 4 times", function () {
-                    expect(itFn.callCount).toEqual(4);
-                });
-
-                it("should call the iterate function with correct arguments", function () {
-                    expect(itFn.calls[0].args).toEqual([6, 0, arr]);
-                    expect(itFn.calls[1].args).toEqual([7, 1, arr]);
-                    expect(itFn.calls[2].args).toEqual([8, 2, arr]);
-                    expect(itFn.calls[3].args).toEqual([9, 3, arr]);
-                });
-             });
-
-            describe("if itFn return false", function() {
-                beforeEach(function() {
-                    itFn.andReturn(false);
-                    Ext.iterate(arr, itFn);
-                });
-
-                it("should stop iteration if function return false", function() {
-                    itFn.andReturn(false);
-
-                    expect(itFn.calls.length).toEqual(1);
-                });
-            });
-        });
-
-        describe("do nothing on an empty array", function() {
-            var arr;
-
-            beforeEach(function() {
-                arr = [];
-                Ext.iterate(arr, itFn);
-            });
-
-            it("should not call the iterate function", function () {
-                expect(itFn).not.toHaveBeenCalled();
-            });
-
-        });
-    });
 
 
     describe("Ext.num", function() {
@@ -535,21 +137,6 @@ describe("Ext-mess", function() {
         });
     });
 
-    xdescribe("Ext.urlAppend", function() {
-        var url = "http://example.com/";
-
-        it("should manage question mark", function() {
-            expect(Ext.urlAppend(url, "test=1")).toEqual("http://example.com/?test=1");
-        });
-
-        it("should manage ampersand", function() {
-            expect(Ext.urlAppend(url+"?test=1","foo=2")).toEqual("http://example.com/?test=1&foo=2");
-        });
-
-        it("should return directly url if content is empty", function() {
-            expect(Ext.urlAppend(url)).toEqual(url);
-        });
-    });
 
     xdescribe("Ext.urlDecode", function() {
         it ("should return an empty object if string is empty", function (){
@@ -601,66 +188,11 @@ describe("Ext-mess", function() {
         });
     });
 
-    xdescribe("Ext.htmlEncode", function() {
-        it("should call Ext.String.htmlEncode", function() {
-            var val = '';
-            spyOn(Ext.util.Format, "htmlEncode");
-            Ext.htmlEncode(val);
-            expect(Ext.String.htmlEncode).toHaveBeenCalledWith(val);
-        });
-    });
 
-    xdescribe("Ext.htmlEncode", function() {
-        it("should call Ext.String.htmlDecode", function() {
-            var val = '';
-            spyOn(Ext.util.Format, "htmlDecode");
 
-            Ext.htmlDecode(val);
-            expect(Ext.String.htmlDecode).toHaveBeenCalledWith(val);
-        });
-    });
 
-    describe("Ext.getBody", function() {
-        it("should return current document body as an Ext.core.Element", function() {
-            expect(Ext.getBody()).toEqual(Ext.get(document.body)); // see initSandbox in DomSandBox.js for more info
-        });
-    });
 
-    describe("Ext.getHead", function() {
-        it("should return current document head as an Ext.core.Element", function() {
-            expect(Ext.getHead()).toEqual(Ext.get(document.getElementsByTagName("head")[0]));
-        });
-    });
 
-    describe("Ext.getDoc", function() {
-        it("should return the current HTML document object as an Ext.element", function() {
-            expect(Ext.getDoc()).toEqual(Ext.get(document));
-        });
-    });
 
-    describe("Ext.getOrientation", function() {
-        it("should return the current orientation of the mobile device", function() {
-            if (window.innerHeight > window.innerWidth) {
-                expect(Ext.getOrientation()).toEqual("portrait");
-            } else {
-                expect(Ext.getOrientation()).toEqual("landscape");
-            }
-        });
-    });
-
-    describe("Ext.getDom", function() {
-        var el1;
-
-        beforeEach(function() {
-            el1 = Ext.getBody().createChild({id: "elone"});
-        });
-
-        it("should return a dom element if an Ext.element is passed as first argument", function() {
-            expect(Ext.getDom(el1)).toEqual(el1.dom);
-        });
 
-        it("should return a dom element if the string (id) passed as first argument", function() {
-            expect(Ext.getDom("elone")).toEqual(el1.dom);
-        });
-    });
 });