File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed
Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change 11<template >
22 <div class =" form-group" >
3- <label v-if =" form[key].label" >{{form[key].label}}</label >
4- <input class =" form-control" :type =" form[key].inputType" v-model =" form[key].value" :placeholder =" form[key].placeholder" >
3+ <label v-if =" form[key].label" :for = " form[key].id ? form[key].id : null " >{{form[key].label}}</label >
4+ <input class =" form-control" :id = " form[key].id ? form[key].id : null " : type =" form[key].inputType" v-model =" form[key].value" :placeholder =" form[key].placeholder" >
55 </div >
66</template >
77
Original file line number Diff line number Diff line change @@ -39,17 +39,23 @@ describe('components', () => {
3939 data . form . test . type = 'input' ;
4040 data . form . test . inputType = 'text' ;
4141 data . form . test . placeholder = 'holding' ;
42+ data . form . test . id = 'someId' ;
4243 createForm ( data ) ;
4344
4445 let inputs = vm . $el . querySelectorAll ( 'input' ) ;
4546 let input = inputs [ 0 ] ;
47+ let labels = vm . $el . querySelectorAll ( 'label' ) ;
48+ let label = labels [ 0 ] ;
4649
4750 expect ( inputs ) . to . be . length ( 1 ) ;
4851 expect ( input . type ) . to . equal ( 'text' ) ;
49- expect ( vm . $el . querySelectorAll ( 'label' ) ) . to . be . length ( 1 ) ;
50- expect ( vm . $el . querySelectorAll ( 'label' ) [ 0 ] . textContent ) . to . equal ( data . form . test . label ) ;
51- expect ( vm . $el . querySelectorAll ( 'input.form-control' ) ) . to . be . length ( 1 ) ;
52+ expect ( input . id ) . to . equal ( data . form . test . id ) ;
5253 expect ( input . placeholder ) . to . equal ( 'holding' ) ;
54+ expect ( input . className ) . to . equal ( 'form-control' ) ;
55+
56+ expect ( labels ) . to . be . length ( 1 ) ;
57+ expect ( label . textContent ) . to . equal ( data . form . test . label ) ;
58+ expect ( label . htmlFor ) . to . equal ( data . form . test . id ) ;
5359
5460 vm . form . test . value = 'testing' ;
5561
@@ -70,5 +76,7 @@ describe('components', () => {
7076 expect ( vm . $el . querySelectorAll ( 'label' ) ) . to . be . length ( 0 ) ;
7177 } ) ;
7278 } ) ;
79+
80+
7381
7482} ) ;
You can’t perform that action at this time.
0 commit comments