]> git.proxmox.com Git - extjs.git/blame - extjs/classic/classic/test/specs/layout/component/field/FieldContainer.js
add extjs 6.0.1 sources
[extjs.git] / extjs / classic / classic / test / specs / layout / component / field / FieldContainer.js
CommitLineData
6527f429
DM
1describe("Ext.layout.component.field.FieldContainer", function() {\r
2 \r
3 it("should account for left/right any padding supplied by the fieldBodyCls", function() {\r
4 var fc = Ext.create('Ext.form.FieldContainer', {\r
5 renderTo: Ext.getBody(),\r
6 hideLabel: true,\r
7 layout: {\r
8 type: 'hbox',\r
9 align: 'stretch'\r
10 },\r
11 width: 300,\r
12 height: 50,\r
13 defaultType: 'component',\r
14 items: [{\r
15 flex: 1\r
16 }, {\r
17 flex: 1\r
18 }]\r
19 });\r
20 // Simulate bodyCls setting padding: 1px\r
21 fc.bodyEl.setStyle('padding', '1px');\r
22 fc.updateLayout();\r
23 expect(fc.items.first().getWidth()).toBe(149);\r
24 expect(fc.items.last().getWidth()).toBe(149);\r
25 fc.destroy();\r
26 });\r
27 \r
28 it("should account for top/bottom any padding supplied by the fieldBodyCls", function() {\r
29 var fc = Ext.create('Ext.form.FieldContainer', {\r
30 renderTo: Ext.getBody(),\r
31 hideLabel: true,\r
32 layout: {\r
33 type: 'hbox',\r
34 align: 'stretch'\r
35 },\r
36 width: 300,\r
37 height: 50,\r
38 items: [{\r
39 xtype: 'component',\r
40 flex: 1\r
41 }]\r
42 });\r
43 // Simulate bodyCls setting padding: 1px\r
44 fc.bodyEl.setStyle('padding', '1px');\r
45 fc.updateLayout();\r
46 expect(fc.items.first().getHeight()).toBe(48);\r
47 fc.destroy();\r
48 });\r
49\r
50 it("should correctly measure content height when its container layout is hbox", function() {\r
51 // EXTJSIV-12665\r
52 var panel = Ext.widget({\r
53 xtype: 'panel',\r
54 renderTo: document.body,\r
55 layout: 'anchor',\r
56 bodyPadding: 10,\r
57 items: [{\r
58 xtype: 'fieldcontainer',\r
59 id: 'field-ct',\r
60 layout: 'hbox',\r
61 items: [{\r
62 xtype: 'component',\r
63 style: 'height: 22px; width: 150px; background-color: green;',\r
64 html: ' '\r
65 }]\r
66 }]\r
67 });\r
68\r
69 expect(panel.getHeight()).toBe(49);\r
70 expect(Ext.getCmp('field-ct').getHeight()).toBe(22);\r
71\r
72 panel.destroy();\r
73 });\r
74\r
75 it("should shrink wrap liquid layout children when using a box layout", function() {\r
76 var fc = Ext.widget({\r
77 xtype: 'fieldcontainer',\r
78 renderTo: document.body,\r
79 layout: 'hbox',\r
80 items: [{\r
81 xtype: 'textfield',\r
82 width: 300,\r
83 value: 'foo'\r
84 }]\r
85 });\r
86\r
87 expect(fc.getHeight()).toBe(22);\r
88 expect(fc.getWidth()).toBe(300);\r
89 fc.destroy();\r
90 });\r
91\r
92 it("should publish the correct inner width for the layout of its items", function() {\r
93 var fc = Ext.widget({\r
94 renderTo: document.body,\r
95 xtype: 'fieldcontainer',\r
96 width: 500,\r
97 fieldLabel: 'Label',\r
98 msgTarget : 'side',\r
99 layout: 'hbox',\r
100 items: [{\r
101 flex: 1,\r
102 xtype: 'textfield'\r
103 }]\r
104 });\r
105\r
106 expect(fc.getWidth()).toBe(500);\r
107 expect(fc.labelEl.getWidth()).toBe(105);\r
108 expect(fc.bodyEl.getWidth()).toBe(395);\r
109 expect(fc.items.getAt(0).getWidth()).toBe(395);\r
110\r
111 // make sure the child gets resized when side error is shown.\r
112 fc.setActiveError('Error');\r
113\r
114 expect(fc.getWidth()).toBe(500);\r
115 expect(fc.labelEl.getWidth()).toBe(105);\r
116 expect(fc.bodyEl.getWidth()).toBe(377);\r
117 expect(fc.errorWrapEl.getWidth()).toBe(18);\r
118 expect(fc.items.getAt(0).getWidth()).toBe(377);\r
119\r
120 fc.destroy();\r
121 });\r
122\r
123 it("should publish the correct inner height for the layout of its items", function() {\r
124 var fc = Ext.widget({\r
125 renderTo: document.body,\r
126 xtype: 'fieldcontainer',\r
127 height: 200,\r
128 fieldLabel: 'Label',\r
129 labelAlign: 'top',\r
130 msgTarget : 'under',\r
131 layout: 'vbox',\r
132 items: [{\r
133 flex: 1,\r
134 width: 100,\r
135 xtype: 'component',\r
136 style: 'background-color:green;'\r
137 }]\r
138 });\r
139\r
140 expect(fc.getHeight()).toBe(200);\r
141 expect(fc.labelEl.getHeight()).toBe(23);\r
142 expect(fc.bodyEl.getHeight()).toBe(177);\r
143 expect(fc.items.getAt(0).getHeight()).toBe(177);\r
144\r
145 // make sure the child gets resized when side error is shown.\r
146 fc.setActiveError('Error');\r
147\r
148 expect(fc.getHeight()).toBe(200);\r
149 expect(fc.labelEl.getHeight()).toBe(23);\r
150 expect(fc.bodyEl.getHeight()).toBe(157);\r
151 expect(fc.errorWrapEl.getHeight()).toBe(20);\r
152 expect(fc.items.getAt(0).getHeight()).toBe(157);\r
153\r
154 fc.destroy();\r
155 });\r
156});\r