1 describe("Ext-mess", function() {
4 xdescribe("Ext.repaint", function() {
5 it("should create a mask in the body", function(){
6 var body = Ext.getBody();
8 spyOn(Ext, "getBody").andCallThrough();
9 spyOn(body, "createChild").andCallThrough();
13 expect(Ext.getBody).toHaveBeenCalled();
14 expect(body.createChild).toHaveBeenCalledWith({cls: "x-mask x-mask-transparent", tag: "div"});
23 describe("Ext.num", function() {
24 it("should work with an integer", function() {
25 expect(Ext.num(3)).toEqual(3);
28 it("should work with a negative integer", function() {
29 expect(Ext.num(-7)).toEqual(-7);
32 it("should work with a float", function() {
33 expect(Ext.num(5.43)).toEqual(5.43);
36 it("should work with a negative float", function() {
37 expect(Ext.num(-9.8)).toEqual(-9.8);
40 it("should work with Math.PI", function() {
41 expect(Ext.num(Math.PI)).toEqual(Math.PI);
44 it("should return undefined with null", function() {
45 expect(Ext.num(null)).toBeUndefined();
48 it("should work with null, with defaults", function() {
49 expect(Ext.num(null, 4)).toEqual(4);
52 it("should return undefined with undefined", function() {
53 expect(Ext.num(undefined)).toBeUndefined();
56 it("should work with undefined, with defaults", function() {
57 expect(Ext.num(undefined, 42)).toEqual(42);
60 it("should return undefined with boolean", function() {
61 expect(Ext.num(true)).toBeUndefined();
64 it("should work with boolean, with defaults", function() {
65 expect(Ext.num(true, 12)).toEqual(12);
68 it("should return undefined with empty string", function() {
69 expect(Ext.num("")).toBeUndefined();
72 it("should work with string argument in the form of a number", function() {
73 expect(Ext.num('666')).toEqual(666);
76 it("should return undefined with a string containing only spaces", function() {
77 expect(Ext.num(" ")).toBeUndefined();
80 it("should return undefined with non empty string", function() {
81 expect(Ext.num("foo")).toBeUndefined();
84 it("should return undefined with empty array", function() {
85 expect(Ext.num([])).toBeUndefined();
88 it("should return undefined with non empty array", function() {
89 expect(Ext.num([1, 2, 3])).toBeUndefined();
92 it("should return undefined with array with a single item", function() {
93 expect(Ext.num([3])).toBeUndefined();
97 describe("Ext.pluck", function() {
98 it("should return results", function() {
99 var results = Ext.pluck([{
110 expect(results).toEqual([11, 13, 18]);
114 describe("Ext.toArray", function() {
122 beforeEach(function() {
123 div = Ext.getBody().createChild({tag: "div"});
124 span1 = div.createChild({tag: "span"});
125 span2 = div.createChild({tag: "span"});
126 span3 = div.createChild({tag: "span"});
127 span4 = div.createChild({tag: "span"});
128 htmlCollection = div.dom.getElementsByTagName("span");
131 it("should convert iterable to an array", function() {
132 expect(Ext.toArray(htmlCollection)).toEqual([span1.dom, span2.dom, span3.dom, span4.dom]);
135 it("should convert a part of an iterable to an array", function() {
136 expect(Ext.toArray(htmlCollection, 1, 3)).toEqual([span2.dom, span3.dom]);
141 xdescribe("Ext.urlDecode", function() {
142 it ("should return an empty object if string is empty", function (){
143 expect(Ext.urlDecode("")).toEqual({});
146 it("should decode 2 keys", function(){
147 expect(Ext.urlDecode("foo=1&bar=2")).toEqual({
153 it("should decode 2 keys, one of them an array (overwrite off)", function() {
154 expect(Ext.urlDecode("foo=1&bar=2&bar=3&bar=4", false)).toEqual({
160 it("should decode 2 keys, one of them an array (overwrite on)", function() {
161 expect(Ext.urlDecode("foo=1&bar=2&bar=3&bar=4", true)).toEqual({
168 xdescribe("Ext.urlEncode", function() {
169 it("should encode 2 keys", function() {
170 expect(Ext.urlEncode({
173 })).toEqual("foo=1&bar=2");
176 it("should encode 2 keys, one of them an array", function() {
177 expect(Ext.urlEncode({
180 })).toEqual("foo=1&bar=2&bar=3&bar=4");
183 it("should encode 2 keys, one of them an array, with pre: test=1", function() {
184 expect(Ext.urlEncode({
187 }, "test=1")).toEqual("test=1&foo=1&bar=2&bar=3&bar=4");