1 describe("Ext.core.Element.static", function() {
2 var proto = Ext.core.Element,
5 child1, child2, child3;
7 beforeEach(function() {
8 testEl = Ext.getBody().createChild({
9 id : 'ExtElementHelper',
10 style : 'position:absolute;',
12 {id: 'child1', style: 'position:absolute;'},
13 {id: 'child2', style: 'position:absolute;'},
14 {id: 'child3', style: 'position:absolute;'}
18 testInputEl = Ext.getBody().createChild({
19 id : 'ExtElementInputHelper',
24 el = new Ext.core.Element(Ext.getDom(testEl));
25 input = new Ext.core.Element(Ext.getDom(testInputEl));
27 child1 = Ext.get('child1');
28 child2 = Ext.get('child2');
29 child3 = Ext.get('child3');
32 afterEach(function() {
37 it("should have a defaultUnit", function() {
38 expect(proto.defaultUnit).toEqual('px');
41 describe("addUnits", function() {
42 it("should add the defualt unit", function() {
43 expect(proto.addUnits(10)).toEqual('10px');
46 it("should not add the defualt unit", function() {
47 expect(proto.addUnits('10px')).toEqual('10px');
51 describe("parseBox", function() {
52 describe("number", function() {
53 describe("when 1 argument", function() {
54 it("should return an object with correct values", function() {
55 expect(proto.parseBox(10)).toEqual({
65 describe("string", function() {
66 describe("when 1 argument", function() {
67 it("should return an object with correct values", function() {
68 expect(proto.parseBox("10")).toEqual({
77 describe("when 2 arguments", function() {
78 it("should return an object with correct values", function() {
79 expect(proto.parseBox("10 5")).toEqual({
88 describe("when 3 arguments", function() {
89 it("should return an object with correct values", function() {
90 expect(proto.parseBox("10 5 10")).toEqual({
99 describe("when 4 arguments", function() {
100 it("should return an object with correct values", function() {
101 expect(proto.parseBox("10 5 15 0")).toEqual({
112 describe("unitizeBox", function() {
113 it("should return a string", function() {
114 expect(proto.unitizeBox('10 5 15 0')).toEqual('10px 5px 15px 0px');
118 describe("normalize", function() {
119 it("should change border-radius > borderRadius", function() {
120 expect(proto.normalize('border-radius')).toEqual('borderRadius');
124 describe("getDocumentHeight", function() {
125 it("should return the document height", function() {
126 var result = proto.getDocumentHeight();
128 expect(result).toBeDefined();
129 expect(Ext.isNumber(result)).toBeTruthy();
133 describe("getDocumentWidth", function() {
134 it("should return the document width", function() {
135 var result = proto.getDocumentWidth();
137 expect(result).toBeDefined();
138 expect(Ext.isNumber(result)).toBeTruthy();
142 describe("getViewportHeight", function() {
143 it("should return the window height", function() {
144 var result = proto.getViewportHeight();
146 expect(result).toBeDefined();
147 expect(Ext.isNumber(result)).toBeTruthy();
151 describe("getViewportWidth", function() {
152 it("should return the window width", function() {
153 var result = proto.getViewportWidth();
155 expect(result).toBeDefined();
156 expect(Ext.isNumber(result)).toBeTruthy();
160 describe("getViewSize", function() {
161 it("should return the window height and width", function() {
162 expect(proto.getViewSize()).toEqual({
163 width : window.innerWidth,
164 height: window.innerHeight
169 describe("getOrientation", function() {
170 it("should return the correct orientation", function() {
171 expect(proto.getOrientation()).toEqual((window.innerHeight > window.innerWidth) ? 'portrait' : 'landscape');
175 describe("fromPoint", function() {
176 it("should return nothing", function() {
177 expect(proto.fromPoint(-550000, -550000)).toBeNull();
180 }, "/src/dom/Element.static.js");