]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | describe("Ext.Element.style", function() {\r |
2 | var testEl;\r | |
3 | \r | |
4 | beforeEach(function() {\r | |
5 | testEl = Ext.getBody().createChild({\r | |
6 | id : 'ExtElementHelper',\r | |
7 | style : 'position:absolute;'\r | |
8 | });\r | |
9 | });\r | |
10 | \r | |
11 | afterEach(function() {\r | |
12 | testEl.destroy();\r | |
13 | });\r | |
14 | \r | |
15 | describe('addCls', function () {\r | |
16 | xit('should add one class', function () {\r | |
17 | testEl.addCls('foo');\r | |
18 | expect(testEl.dom.className).toEqual('foo');\r | |
19 | });\r | |
20 | \r | |
21 | it('should add two class', function () {\r | |
22 | testEl.addCls('foo').addCls('bar');\r | |
23 | expect(testEl.dom.className).toEqual('foo bar');\r | |
24 | });\r | |
25 | \r | |
26 | xit('should add one class when given duplicates', function () {\r | |
27 | testEl.addCls('foo').addCls('foo');\r | |
28 | expect(testEl.dom.className).toEqual('foo');\r | |
29 | });\r | |
30 | \r | |
31 | xit('should add two class at once', function () {\r | |
32 | testEl.addCls('foo bar').addCls('bar');\r | |
33 | expect(testEl.dom.className).toEqual('foo bar');\r | |
34 | });\r | |
35 | \r | |
36 | xit('should add two class at once and handle duplicates', function () {\r | |
37 | testEl.addCls('foo bar').addCls('bar foo');\r | |
38 | expect(testEl.dom.className).toEqual('foo bar');\r | |
39 | });\r | |
40 | });\r | |
41 | \r | |
42 | describe('removeCls', function () {\r | |
43 | it('should remove nothing if no classes', function () {\r | |
44 | testEl.removeCls('bar');\r | |
45 | expect(testEl.dom.className).toEqual('');\r | |
46 | });\r | |
47 | \r | |
48 | it('should remove nothing if class is not present', function () {\r | |
49 | testEl.dom.className = 'foo bar';\r | |
50 | testEl.removeCls('fbar');\r | |
51 | expect(testEl.dom.className).toEqual('foo bar');\r | |
52 | });\r | |
53 | \r | |
54 | it('should remove only class', function () {\r | |
55 | testEl.dom.className = 'foo';\r | |
56 | testEl.removeCls('foo');\r | |
57 | expect(testEl.dom.className).toEqual('');\r | |
58 | });\r | |
59 | \r | |
60 | it('should remove last class', function () {\r | |
61 | testEl.dom.className = 'foo bar';\r | |
62 | testEl.removeCls('bar');\r | |
63 | expect(testEl.dom.className).toEqual('foo');\r | |
64 | });\r | |
65 | \r | |
66 | it('should remove first class', function () {\r | |
67 | testEl.dom.className = 'foo bar';\r | |
68 | testEl.removeCls('bar');\r | |
69 | expect(testEl.dom.className).toEqual('foo');\r | |
70 | });\r | |
71 | \r | |
72 | it('should remove middle class', function () {\r | |
73 | testEl.dom.className = 'foo bar jazz';\r | |
74 | testEl.removeCls('bar');\r | |
75 | expect(testEl.dom.className).toEqual('foo jazz');\r | |
76 | });\r | |
77 | \r | |
78 | it('should remove multiple classes', function () {\r | |
79 | testEl.dom.className = 'foo bar jazz spud';\r | |
80 | testEl.removeCls('jazz bar fff');\r | |
81 | expect(testEl.dom.className).toEqual('foo spud');\r | |
82 | });\r | |
83 | \r | |
84 | it('should remove multiple classes sequentially', function () {\r | |
85 | testEl.dom.className = 'foo bar jazz spud';\r | |
86 | testEl.removeCls('jazz').removeCls('bar').removeCls('fff');\r | |
87 | expect(testEl.dom.className).toEqual('foo spud');\r | |
88 | });\r | |
89 | });\r | |
90 | \r | |
91 | describe('getStyle', function(){\r | |
92 | var el, dom;\r | |
93 | beforeEach(function(){\r | |
94 | dom = document.createElement('div');\r | |
95 | testEl.appendChild(dom);\r | |
96 | el = Ext.get(dom);\r | |
97 | });\r | |
98 | afterEach(function(){\r | |
99 | el.destroy();\r | |
100 | });\r | |
101 | \r | |
102 | describe('border-*-width', function(){\r | |
103 | Ext.Array.forEach('top right bottom left'.split(' '), function(side){\r | |
104 | it('must report the correct border-'+ side +'-width when the border-'+ side +'-style is "solid"', function(){\r | |
105 | dom.style.cssText = 'border:5px solid';\r | |
106 | expect(el.getStyle('border-'+ side +'-width')).toBe('5px');\r | |
107 | });\r | |
108 | it('must report 0px for border-'+ side +'-width when the border-'+ side +'-style is "none"', function(){\r | |
109 | dom.style.cssText = 'border:5px solid; border-' + side + '-style:none';\r | |
110 | expect(el.getStyle('border-'+ side +'-width')).toBe('0px');\r | |
111 | });\r | |
112 | });\r | |
113 | });\r | |
114 | \r | |
115 | });\r | |
116 | \r | |
117 | describe('setStyle', function() {\r | |
118 | var el, dom;\r | |
119 | beforeEach(function(){\r | |
120 | dom = document.createElement('div');\r | |
121 | testEl.appendChild(dom);\r | |
122 | el = Ext.get(dom);\r | |
123 | });\r | |
124 | afterEach(function(){\r | |
125 | el.destroy();\r | |
126 | });\r | |
127 | \r | |
128 | describe('font-size', function() {\r | |
129 | it('should set the font size', function() {\r | |
130 | el.setStyle('font-size', '50px');\r | |
131 | expect(el.getStyle('font-size')).toEqual('50px');\r | |
132 | });\r | |
133 | });\r | |
134 | \r | |
135 | describe('font-sstyle', function() {\r | |
136 | it('should set the font style', function() {\r | |
137 | el.setStyle('font-style', 'italic');\r | |
138 | expect(el.getStyle('font-style')).toEqual('italic');\r | |
139 | });\r | |
140 | });\r | |
141 | \r | |
142 | describe('font-family', function() {\r | |
143 | it('should set the font family', function() {\r | |
144 | el.setStyle('font-family', 'Courier');\r | |
145 | expect(el.getStyle('font-family').toLowerCase().indexOf('courier')).toBeGreaterThan(-1);\r | |
146 | });\r | |
147 | });\r | |
148 | });\r | |
149 | \r | |
150 | }, "/src/dom/Element.style.js");\r |