@@ -102,12 +102,12 @@ function describeFunctions(formlyElement, inputElement, inputType = 'text', opti
102
102
103
103
function describeAttributes ( inputElement , testPlaceholder = true ) {
104
104
beforeEach ( ( ) => {
105
- data . form . test . type = inputElement ;
106
- data . form . test . inputType = 'text' ;
105
+ data . fields [ 0 ] . type = inputElement ;
106
+ data . fields [ 0 ] . templateOptions . type = 'text' ;
107
107
} ) ;
108
108
109
109
it ( 'attributes' , ( ) => {
110
- data . form . test . atts = {
110
+ data . fields [ 0 ] . templateOptions . atts = {
111
111
'data-foo' : 'bar' ,
112
112
'data-bar' : 'foo' ,
113
113
'placeholder' : 'holding'
@@ -120,7 +120,7 @@ function describeAttributes(inputElement, testPlaceholder = true){
120
120
} ) ;
121
121
122
122
it ( 'classes' , ( ) => {
123
- data . form . test . classes = {
123
+ data . fields [ 0 ] . templateOptions . classes = {
124
124
'class-a' : true ,
125
125
'class-b' : false
126
126
} ;
@@ -130,25 +130,25 @@ function describeAttributes(inputElement, testPlaceholder = true){
130
130
} ) ;
131
131
132
132
it ( 'id' , ( ) => {
133
- data . form . test . id = 'someId' ;
133
+ data . fields [ 0 ] . templateOptions . id = 'someId' ;
134
134
createForm ( ) ;
135
135
let input = vm . $el . querySelectorAll ( inputElement ) [ 0 ] ;
136
136
let label = vm . $el . querySelectorAll ( 'label' ) [ 0 ] ;
137
- expect ( input . id ) . to . equal ( data . form . test . id ) ;
138
- expect ( label . htmlFor ) . to . equal ( data . form . test . id ) ;
137
+ expect ( input . id ) . to . equal ( data . fields [ 0 ] . templateOptions . id ) ;
138
+ expect ( label . htmlFor ) . to . equal ( data . fields [ 0 ] . templateOptions . id ) ;
139
139
} ) ;
140
140
} ;
141
141
142
142
function describeConditional ( inputElement ) {
143
143
it ( 'label' , ( done ) => {
144
- data . form . test . type = inputElement ;
145
- data . form . test . inputType = 'text' ;
146
- data . form . test . label = '' ;
144
+ data . fields [ 0 ] . type = inputElement ;
145
+ data . fields [ 0 ] . templateOptions . type = 'text' ;
146
+ data . fields [ 0 ] . templateOptions . label = '' ;
147
147
createForm ( data ) ;
148
148
149
149
expect ( vm . $el . querySelectorAll ( 'label' ) ) . to . be . length ( 0 ) ;
150
150
151
- vm . form . test . label = 'testing' ;
151
+ vm . fields [ 0 ] . templateOptions . label = 'testing' ;
152
152
153
153
setTimeout ( ( ) => {
154
154
expect ( vm . $el . querySelectorAll ( 'label' ) ) . to . be . length ( 1 ) ;
@@ -184,7 +184,7 @@ describe('Bootstrap Field Inputs', () => {
184
184
} ) ;
185
185
186
186
describe ( 'classes & attributes' , ( ) => {
187
- // describeAttributes('input');
187
+ describeAttributes ( 'input' ) ;
188
188
it ( 'should have input type as a class' , ( ) => {
189
189
data . fields [ 0 ] . type = 'input' ;
190
190
data . fields [ 0 ] . templateOptions . type = 'text' ;
@@ -195,61 +195,62 @@ describe('Bootstrap Field Inputs', () => {
195
195
} ) ;
196
196
} ) ;
197
197
198
- /*
199
- describe('conditional elements', ()=>{
200
- describeConditional('input');
201
- });
202
-
203
- it('layout', (done) => {
204
- data.form.test.type = 'input';
205
- data.form.test.inputType = 'text';
206
- createForm(data);
207
-
208
- let inputs = vm.$el.querySelectorAll('input');
209
- let input = inputs[0];
210
- let labels = vm.$el.querySelectorAll('label');
211
- let label = labels[0];
212
-
213
- expect(inputs).to.be.length(1);
214
- expect(input.type).to.equal('text');
215
- expect(input.className).to.equal('form-control');
216
-
217
- vm.form.test.value = 'testing';
218
-
219
- setTimeout(() => {
220
- expect(vm.$el.querySelectorAll('input')[0].value).to.equal('testing');
221
- done();
222
- }, 0);
223
-
224
- });
225
-
226
- it('adds active and focus classes', (done) => {
227
- data.form.test.type = 'input';
228
- data.form.test.inputType = 'text';
229
- createForm(data);
230
-
231
- expect(vm.$el.querySelectorAll('.formly-has-focus')).to.be.length(0);
232
- expect(vm.$el.querySelectorAll('.formly-has-value')).to.be.length(0);
233
-
234
- trigger(vm.$el.querySelectorAll('input')[0], 'focus');
235
- data.form.test.value = 'test';
236
- setTimeout(()=>{
237
- expect(vm.$el.querySelectorAll('.formly-has-focus')).to.be.length(1);
238
- expect(vm.$el.querySelectorAll('.formly-has-value')).to.be.length(1);
239
- done();
240
- },0);
241
- });
242
-
243
- it('defaults to text', () => {
244
- data.form.test.type = 'input';
245
- data.form.test.inputType = '';
246
- createForm(data);
247
-
248
- let inputs = vm.$el.querySelectorAll('input');
249
- let input = inputs[0];
250
- expect(input.type).to.equal('text');
251
- });
252
- */
198
+
199
+ describe ( 'conditional elements' , ( ) => {
200
+ describeConditional ( 'input' ) ;
201
+ } ) ;
202
+
203
+
204
+ it ( 'layout' , ( done ) => {
205
+ data . fields [ 0 ] . type = 'input' ;
206
+ data . fields [ 0 ] . templateOptions . type = 'text' ;
207
+ createForm ( data ) ;
208
+
209
+ let inputs = vm . $el . querySelectorAll ( 'input' ) ;
210
+ let input = inputs [ 0 ] ;
211
+ let labels = vm . $el . querySelectorAll ( 'label' ) ;
212
+ let label = labels [ 0 ] ;
213
+
214
+ expect ( inputs ) . to . be . length ( 1 ) ;
215
+ expect ( input . type ) . to . equal ( 'text' ) ;
216
+ expect ( input . className ) . to . equal ( 'form-control' ) ;
217
+
218
+ vm . model . test = 'testing' ;
219
+
220
+ setTimeout ( ( ) => {
221
+ expect ( vm . $el . querySelectorAll ( 'input' ) [ 0 ] . value ) . to . equal ( 'testing' ) ;
222
+ done ( ) ;
223
+ } , 0 ) ;
224
+
225
+ } ) ;
226
+
227
+ it ( 'adds active and focus classes' , ( done ) => {
228
+ data . fields [ 0 ] . type = 'input' ;
229
+ data . fields [ 0 ] . templateOptions . type = 'text' ;
230
+ createForm ( data ) ;
231
+
232
+ expect ( vm . $el . querySelectorAll ( '.formly-has-focus' ) ) . to . be . length ( 0 ) ;
233
+ expect ( vm . $el . querySelectorAll ( '.formly-has-value' ) ) . to . be . length ( 0 ) ;
234
+
235
+ trigger ( vm . $el . querySelectorAll ( 'input' ) [ 0 ] , 'focus' ) ;
236
+ data . model . test = 'test' ;
237
+ setTimeout ( ( ) => {
238
+ expect ( vm . $el . querySelectorAll ( '.formly-has-focus' ) ) . to . be . length ( 1 ) ;
239
+ expect ( vm . $el . querySelectorAll ( '.formly-has-value' ) ) . to . be . length ( 1 ) ;
240
+ done ( ) ;
241
+ } , 0 ) ;
242
+ } ) ;
243
+
244
+ it ( 'defaults to text' , ( ) => {
245
+ data . fields [ 0 ] . type = 'input' ;
246
+ data . fields [ 0 ] . templateOptions . type = undefined ;
247
+ createForm ( data ) ;
248
+
249
+ let inputs = vm . $el . querySelectorAll ( 'input' ) ;
250
+ let input = inputs [ 0 ] ;
251
+ expect ( input . type ) . to . equal ( 'text' ) ;
252
+ } ) ;
253
+
253
254
} ) ;
254
255
255
256
0 commit comments