/ext-4.1.0_b3/src/core/test/unit/spec/dom/Element.style.js
JavaScript | 118 lines | 99 code | 19 blank | 0 comment | 3 complexity | eb3e9a849d592c4cae61786a2e8dd70e MD5 | raw file
1describe("Ext.Element.style", function() {
2 var testEl;
3
4 beforeEach(function() {
5 testEl = Ext.getBody().createChild({
6 id : 'ExtElementHelper',
7 style : 'position:absolute;'
8 });
9 });
10
11 afterEach(function() {
12 testEl.remove();
13 });
14
15 describe('addCls', function () {
16 xit('should add one class', function () {
17 testEl.addCls('foo');
18 expect(testEl.dom.className).toEqual('foo');
19 });
20
21 it('should add two class', function () {
22 testEl.addCls('foo').addCls('bar');
23 expect(testEl.dom.className).toEqual('foo bar');
24 });
25
26 xit('should add one class when given duplicates', function () {
27 testEl.addCls('foo').addCls('foo');
28 expect(testEl.dom.className).toEqual('foo');
29 });
30
31 xit('should add two class at once', function () {
32 testEl.addCls('foo bar').addCls('bar');
33 expect(testEl.dom.className).toEqual('foo bar');
34 });
35
36 xit('should add two class at once and handle duplicates', function () {
37 testEl.addCls('foo bar').addCls('bar foo');
38 expect(testEl.dom.className).toEqual('foo bar');
39 });
40 });
41
42 describe('removeCls', function () {
43 it('should remove nothing if no classes', function () {
44 testEl.removeCls('bar');
45 expect(testEl.dom.className).toEqual('');
46 });
47
48 it('should remove nothing if class is not present', function () {
49 testEl.dom.className = 'foo bar';
50 testEl.removeCls('fbar');
51 expect(testEl.dom.className).toEqual('foo bar');
52 });
53
54 it('should remove only class', function () {
55 testEl.dom.className = 'foo';
56 testEl.removeCls('foo');
57 expect(testEl.dom.className).toEqual('');
58 });
59
60 it('should remove last class', function () {
61 testEl.dom.className = 'foo bar';
62 testEl.removeCls('bar');
63 expect(testEl.dom.className).toEqual('foo');
64 });
65
66 it('should remove first class', function () {
67 testEl.dom.className = 'foo bar';
68 testEl.removeCls('bar');
69 expect(testEl.dom.className).toEqual('foo');
70 });
71
72 it('should remove middle class', function () {
73 testEl.dom.className = 'foo bar jazz';
74 testEl.removeCls('bar');
75 expect(testEl.dom.className).toEqual('foo jazz');
76 });
77
78 it('should remove multiple classes', function () {
79 testEl.dom.className = 'foo bar jazz spud';
80 testEl.removeCls('jazz bar fff');
81 expect(testEl.dom.className).toEqual('foo spud');
82 });
83
84 it('should remove multiple classes sequentially', function () {
85 testEl.dom.className = 'foo bar jazz spud';
86 testEl.removeCls('jazz').removeCls('bar').removeCls('fff');
87 expect(testEl.dom.className).toEqual('foo spud');
88 });
89 });
90
91 describe('getStyle', function(){
92 var el, dom;
93 beforeEach(function(){
94 dom = document.createElement('div');
95 testEl.appendChild(dom);
96 el = new Ext.Element(dom);
97 });
98 afterEach(function(){
99 dom.parentNode.removeChild(dom);
100 el = dom = null;
101 });
102
103 describe('border-*-width', function(){
104 Ext.Array.forEach('top right bottom left'.split(' '), function(side){
105 it('must report the correct border-'+ side +'-width when the border-'+ side +'-style is "solid"', function(){
106 dom.style.cssText = 'border:5px solid';
107 expect(el.getStyle('border-'+ side +'-width')).toBe('5px');
108 });
109 it('must report 0px for border-'+ side +'-width when the border-'+ side +'-style is "none"', function(){
110 dom.style.cssText = 'border:5px solid; border-' + side + '-style:none';
111 expect(el.getStyle('border-'+ side +'-width')).toBe('0px');
112 });
113 });
114 });
115
116 });
117
118}, "/src/dom/Element.style.js");