1 | /*! |
---|
2 | * Ext JS Library 3.4.0 |
---|
3 | * Copyright(c) 2006-2011 Sencha Inc. |
---|
4 | * licensing@sencha.com |
---|
5 | * http://www.sencha.com/license |
---|
6 | */ |
---|
7 | /** |
---|
8 | * Tests Ext.data.Store functionality |
---|
9 | * @author Ed Spencer |
---|
10 | */ |
---|
11 | (function() { |
---|
12 | var suite = Ext.test.session.getSuite('Ext.layout.FormLayout'), |
---|
13 | assert = Y.Assert; |
---|
14 | |
---|
15 | function buildLayout(config) { |
---|
16 | var layout = new Ext.layout.FormLayout(config || {}); |
---|
17 | |
---|
18 | //give a mock container |
---|
19 | layout.container = { |
---|
20 | itemCls: 'ctCls' |
---|
21 | }; |
---|
22 | |
---|
23 | return layout; |
---|
24 | }; |
---|
25 | |
---|
26 | suite.add(new Y.Test.Case({ |
---|
27 | name: 'getTemplateArgs', |
---|
28 | |
---|
29 | setUp: function() { |
---|
30 | this.layout = buildLayout({ |
---|
31 | labelStyle : 'color: red;', |
---|
32 | elementStyle: 'padding-left:0;' |
---|
33 | }); |
---|
34 | |
---|
35 | //mock fields |
---|
36 | this.field1 = { |
---|
37 | id : 'myField', |
---|
38 | itemCls : 'myCls', |
---|
39 | clearCls : 'myClearCls', |
---|
40 | fieldLabel: 'A Label', |
---|
41 | labelStyle: 'border-top: 10px;' |
---|
42 | }; |
---|
43 | |
---|
44 | this.field2 = { |
---|
45 | id : 'myField2', |
---|
46 | fieldLabel : 'My Label', |
---|
47 | labelSeparator: '@' |
---|
48 | }; |
---|
49 | |
---|
50 | this.field3 = Ext.apply({}, { |
---|
51 | fieldLabel: 'Third label', |
---|
52 | hideLabel : true |
---|
53 | }, this.field2); |
---|
54 | |
---|
55 | this.args1 = this.layout.getTemplateArgs(this.field1); |
---|
56 | this.args2 = this.layout.getTemplateArgs(this.field2); |
---|
57 | this.args3 = this.layout.getTemplateArgs(this.field3); |
---|
58 | }, |
---|
59 | |
---|
60 | testId: function() { |
---|
61 | assert.areEqual('myField', this.args1.id); |
---|
62 | assert.areEqual('myField2', this.args2.id); |
---|
63 | }, |
---|
64 | |
---|
65 | testLabel: function() { |
---|
66 | assert.areEqual('A Label', this.args1.label); |
---|
67 | assert.areEqual('My Label', this.args2.label); |
---|
68 | assert.areEqual('Third label', this.args3.label); |
---|
69 | }, |
---|
70 | |
---|
71 | //adds field's label style to layout's general label style |
---|
72 | testLabelStyle: function() { |
---|
73 | assert.areEqual('color: red;border-top: 10px;', this.args1.labelStyle); |
---|
74 | }, |
---|
75 | |
---|
76 | testElementStyle: function() { |
---|
77 | assert.areEqual('padding-left:0;', this.args1.elementStyle); |
---|
78 | }, |
---|
79 | |
---|
80 | testLabelSeparator: function() { |
---|
81 | assert.areEqual(':', this.args1.labelSeparator); |
---|
82 | assert.areEqual('@', this.args2.labelSeparator); |
---|
83 | assert.areEqual('', this.args3.labelSeparator); |
---|
84 | }, |
---|
85 | |
---|
86 | testItemCls: function() { |
---|
87 | assert.areEqual('myCls', this.args1.itemCls); |
---|
88 | assert.areEqual('ctCls', this.args2.itemCls); |
---|
89 | assert.areEqual('ctCls x-hide-label', this.args3.itemCls); |
---|
90 | }, |
---|
91 | |
---|
92 | testClearCls: function() { |
---|
93 | assert.areEqual('myClearCls', this.args1.clearCls); |
---|
94 | assert.areEqual('x-form-clear-left', this.args2.clearCls); |
---|
95 | } |
---|
96 | })); |
---|
97 | })(); |
---|