@@ -177,6 +177,29 @@ describe('Bootstrap Field Inputs', () => {
177177 } ;
178178 } ) ;
179179
180+ describe ( 'Errors' , ( ) => {
181+ it ( 'should receive an error state' , ( done ) => {
182+ data . fields [ 0 ] . type = 'input' ;
183+ data . fields [ 0 ] . required = true ;
184+ createForm ( ) ;
185+
186+ expect ( data . form [ 'test' ] . $hasError ) . to . be . false ;
187+ trigger ( vm . $el . querySelectorAll ( 'input' ) [ 0 ] , 'focus' ) ;
188+ expect ( data . form [ 'test' ] . $hasError ) . to . be . false ;
189+ expect ( data . form [ 'test' ] . $active ) . to . be . true ;
190+
191+ trigger ( vm . $el . querySelectorAll ( 'input' ) [ 0 ] , 'change' ) ;
192+ trigger ( vm . $el . querySelectorAll ( 'input' ) [ 0 ] , 'blur' ) ;
193+ expect ( data . form [ 'test' ] . $dirty ) . to . be . true ;
194+ expect ( data . form [ 'test' ] . $active ) . to . be . false ;
195+ setTimeout ( ( ) => {
196+ expect ( data . form [ 'test' ] . $hasError ) . to . be . true ;
197+ expect ( vm . $el . querySelectorAll ( '.has-error' ) ) . to . be . length ( 1 ) ;
198+ done ( ) ;
199+ } , 0 ) ;
200+ } ) ;
201+ } ) ;
202+
180203 describe ( 'Input' , ( ) => {
181204
182205 describe ( 'functions' , ( ) => {
@@ -445,6 +468,28 @@ describe('Bootstrap Field Inputs', () => {
445468 done ( ) ;
446469 } , 0 ) ;
447470 } ) ;
471+
472+ it ( 'only shows a checkbox' , ( ) => {
473+ data . fields [ 0 ] . type = 'list' ;
474+ data . fields [ 0 ] . options = [ 'one' , 'two' ] ;
475+ createForm ( ) ;
476+ let inputs = vm . $el . querySelectorAll ( 'input' ) ;
477+ expect ( inputs ) . to . be . length ( 2 ) ;
478+ expect ( inputs [ 0 ] . type ) . to . equal ( 'checkbox' ) ;
479+ expect ( inputs [ 1 ] . type ) . to . equal ( 'checkbox' ) ;
480+ } ) ;
481+
482+ it ( 'only shows a radio box' , ( ) => {
483+ data . fields [ 0 ] . type = 'list' ;
484+ data . fields [ 0 ] . templateOptions . inputType = 'radio' ;
485+ data . fields [ 0 ] . options = [ 'one' , 'two' ] ;
486+ createForm ( ) ;
487+ let inputs = vm . $el . querySelectorAll ( 'input' ) ;
488+ expect ( inputs ) . to . be . length ( 2 ) ;
489+ expect ( inputs [ 0 ] . type ) . to . equal ( 'radio' ) ;
490+ expect ( inputs [ 1 ] . type ) . to . equal ( 'radio' ) ;
491+ } ) ;
492+
448493 } ) ;
449494
450495} ) ;
0 commit comments