3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
9 GNU General Public License Usage
10 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.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
15 describe("Ext.Element.static", function() {
16 var proto = Ext.Element,
19 child1, child2, child3;
21 beforeEach(function() {
22 testEl = Ext.getBody().createChild({
23 id : 'ExtElementHelper',
24 style : 'position:absolute;',
26 {id: 'child1', style: 'position:absolute;'},
27 {id: 'child2', style: 'position:absolute;'},
28 {id: 'child3', style: 'position:absolute;'}
32 testInputEl = Ext.getBody().createChild({
33 id : 'ExtElementInputHelper',
38 el = new Ext.Element(Ext.getDom(testEl));
39 input = new Ext.Element(Ext.getDom(testInputEl));
41 child1 = Ext.get('child1');
42 child2 = Ext.get('child2');
43 child3 = Ext.get('child3');
46 afterEach(function() {
51 it("should have a defaultUnit", function() {
52 expect(proto.defaultUnit).toEqual('px');
55 describe("addUnits", function() {
56 it("should add the defualt unit", function() {
57 expect(proto.addUnits(10)).toEqual('10px');
60 it("should not add the defualt unit", function() {
61 expect(proto.addUnits('10px')).toEqual('10px');
65 describe("parseBox", function() {
66 describe("number", function() {
67 describe("when 1 argument", function() {
68 it("should return an object with correct values", function() {
69 expect(proto.parseBox(10)).toEqual({
79 describe("string", function() {
80 describe("when 1 argument", function() {
81 it("should return an object with correct values", function() {
82 expect(proto.parseBox("10")).toEqual({
91 describe("when 2 arguments", function() {
92 it("should return an object with correct values", function() {
93 expect(proto.parseBox("10 5")).toEqual({
102 describe("when 3 arguments", function() {
103 it("should return an object with correct values", function() {
104 expect(proto.parseBox("10 5 10")).toEqual({
113 describe("when 4 arguments", function() {
114 it("should return an object with correct values", function() {
115 expect(proto.parseBox("10 5 15 0")).toEqual({
126 describe("unitizeBox", function() {
127 it("should return a string", function() {
128 expect(proto.unitizeBox('10 5 15 0')).toEqual('10px 5px 15px 0px');
132 describe("normalize", function() {
133 it("should change border-radius > borderRadius", function() {
134 expect(proto.normalize('border-radius')).toEqual('borderRadius');
138 describe("getDocumentHeight", function() {
139 it("should return the document height", function() {
140 var result = proto.getDocumentHeight();
142 expect(result).toBeDefined();
143 expect(Ext.isNumber(result)).toBeTruthy();
147 describe("getDocumentWidth", function() {
148 it("should return the document width", function() {
149 var result = proto.getDocumentWidth();
151 expect(result).toBeDefined();
152 expect(Ext.isNumber(result)).toBeTruthy();
156 describe("getViewportHeight", function() {
157 it("should return the window height", function() {
158 var result = proto.getViewportHeight();
160 expect(result).toBeDefined();
161 expect(Ext.isNumber(result)).toBeTruthy();
165 describe("getViewportWidth", function() {
166 it("should return the window width", function() {
167 var result = proto.getViewportWidth();
169 expect(result).toBeDefined();
170 expect(Ext.isNumber(result)).toBeTruthy();
174 describe("getViewSize", function() {
175 it("should return the window height and width", function() {
176 expect(proto.getViewSize()).toEqual({
177 width : window.innerWidth,
178 height: window.innerHeight
183 describe("getOrientation", function() {
184 it("should return the correct orientation", function() {
185 expect(proto.getOrientation()).toEqual((window.innerHeight > window.innerWidth) ? 'portrait' : 'landscape');
189 if (!Ext.isSafari3 && !Ext.isSafari4) {
190 describe("fromPoint", function() {
191 it("should return nothing", function() {
192 expect(proto.fromPoint(-550000, -550000)).toBeNull();
196 }, "/src/dom/Element.static.js");