]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | describe("Ext.form.Label", function() {\r |
2 | var component;\r | |
3 | \r | |
4 | function makeComponent(config) {\r | |
5 | component = new Ext.form.Label(Ext.apply({\r | |
6 | name: 'test'\r | |
7 | }, config));\r | |
8 | }\r | |
9 | \r | |
10 | afterEach(function() {\r | |
11 | if (component) {\r | |
12 | Ext.destroy(component);\r | |
13 | }\r | |
14 | component = null;\r | |
15 | });\r | |
16 | \r | |
17 | it("should have a label as the element", function(){\r | |
18 | makeComponent({\r | |
19 | renderTo: Ext.getBody()\r | |
20 | });\r | |
21 | \r | |
22 | expect(component.el.dom.tagName.toUpperCase()).toEqual("LABEL");\r | |
23 | });\r | |
24 | \r | |
25 | it("should use the forId attribute", function(){\r | |
26 | makeComponent({\r | |
27 | renderTo: Ext.getBody(),\r | |
28 | forId: "foo"\r | |
29 | });\r | |
30 | \r | |
31 | expect(component.el.dom.htmlFor).toEqual("foo");\r | |
32 | });\r | |
33 | \r | |
34 | it("should encode the text attribute", function(){\r | |
35 | makeComponent({\r | |
36 | text: "<div>foo</div>",\r | |
37 | renderTo: Ext.getBody()\r | |
38 | });\r | |
39 | \r | |
40 | expect(component.el.dom).hasHTML("<div>foo</div>");\r | |
41 | });\r | |
42 | \r | |
43 | it("should not encode the html attribute", function(){\r | |
44 | makeComponent({\r | |
45 | html: "<span>foo</span>",\r | |
46 | renderTo: Ext.getBody()\r | |
47 | });\r | |
48 | expect(component.el.dom).hasHTML("<span>foo</span>");\r | |
49 | });\r | |
50 | \r | |
51 | it("should support setText when not rendered", function(){\r | |
52 | makeComponent();\r | |
53 | component.setText("foo");\r | |
54 | component.render(Ext.getBody());\r | |
55 | expect(component.el.dom).hasHTML("foo");\r | |
56 | component.destroy();\r | |
57 | \r | |
58 | makeComponent({\r | |
59 | text: "foo"\r | |
60 | });\r | |
61 | component.setText("bar");\r | |
62 | component.render(Ext.getBody());\r | |
63 | expect(component.el.dom).hasHTML("bar");\r | |
64 | });\r | |
65 | \r | |
66 | it("should enforce the encode attribute", function(){\r | |
67 | makeComponent();\r | |
68 | component.setText("<b>bar</b>", false);\r | |
69 | component.render(Ext.getBody());\r | |
70 | expect(component.el.dom).hasHTML("<b>bar</b>");\r | |
71 | \r | |
72 | component.setText("<span>foo</span>");\r | |
73 | expect(component.el.dom).hasHTML("<span>foo</span>");\r | |
74 | \r | |
75 | component.setText("<span>bar</span>", false);\r | |
76 | expect(component.el.dom).hasHTML("<span>bar</span>");\r | |
77 | });\r | |
78 | \r | |
79 | it("should update the layout when text is set after render", function(){\r | |
80 | makeComponent({\r | |
81 | renderTo: document.body\r | |
82 | }); \r | |
83 | var width = component.getWidth();\r | |
84 | component.setText('New text');\r | |
85 | expect(component.getWidth()).toBeGreaterThan(width);\r | |
86 | });\r | |
87 | });\r |