@@ -20,6 +20,7 @@ describe("fieldSelectEx.vue", () => {
2020 label : "Cities" ,
2121 model : "city" ,
2222 multiSelect : false ,
23+ required : false ,
2324 values : [
2425 "London" ,
2526 "Paris" ,
@@ -47,13 +48,19 @@ describe("fieldSelectEx.vue", () => {
4748
4849 it ( "should contain option elements" , ( ) => {
4950 let options = input . querySelectorAll ( "option" ) ;
50- expect ( options . length ) . to . be . equal ( 4 ) ;
51+ expect ( options . length ) . to . be . equal ( 4 + 1 ) ; // +1 for <non selected>
5152
52- expect ( options [ 1 ] . value ) . to . be . equal ( "Paris" ) ;
53- expect ( options [ 1 ] . textContent ) . to . be . equal ( "Paris" ) ;
54- expect ( options [ 1 ] . selected ) . to . be . true ;
53+ expect ( options [ 2 ] . value ) . to . be . equal ( "Paris" ) ;
54+ expect ( options [ 2 ] . textContent ) . to . be . equal ( "Paris" ) ;
55+ expect ( options [ 2 ] . selected ) . to . be . true ;
5556 } ) ;
5657
58+ it ( "should contain a <non selected> element" , ( ) => {
59+ let options = input . querySelectorAll ( "option" ) ;
60+ expect ( options [ 0 ] . disabled ) . to . be . false ;
61+ expect ( options [ 0 ] . textContent ) . to . be . equal ( "<Not selected>" ) ;
62+ } ) ;
63+
5764 it ( "should contain the value" , ( done ) => {
5865 vm . $nextTick ( ( ) => {
5966 expect ( input . value ) . to . be . equal ( "Paris" ) ;
@@ -89,10 +96,23 @@ describe("fieldSelectEx.vue", () => {
8996
9097 } ) ;
9198
99+ it ( "should contain a disabled <non selected> element if required" , ( done ) => {
100+ schema . required = true ;
101+ vm . $nextTick ( ( ) => {
102+ let options = input . querySelectorAll ( "option" ) ;
103+ //expect(options[0].disabled).to.be.true;
104+ expect ( options [ 0 ] . textContent ) . to . be . equal ( "<Not selected>" ) ;
105+ done ( ) ;
106+ } ) ;
107+ } ) ;
108+
92109 it ( "should not be multiple" , ( done ) => {
93110 schema . multiSelect = true ;
94111 vm . $nextTick ( ( ) => {
95112 expect ( input . multiple ) . to . be . true ;
113+ let options = input . querySelectorAll ( "option" ) ;
114+ expect ( options . length ) . to . be . equal ( 4 ) ; // no <non selected>
115+
96116 done ( ) ;
97117 } ) ;
98118 } ) ;
@@ -121,12 +141,12 @@ describe("fieldSelectEx.vue", () => {
121141
122142 it ( "should contain option elements" , ( ) => {
123143 let options = input . querySelectorAll ( "option" ) ;
124- expect ( options . length ) . to . be . equal ( 4 ) ;
144+ expect ( options . length ) . to . be . equal ( 4 + 1 ) ; // +1 for <non selected>
125145
126- expect ( options [ 1 ] . value ) . to . be . equal ( "2" ) ;
127- expect ( options [ 1 ] . textContent ) . to . be . equal ( "Paris" ) ;
128- expect ( options [ 1 ] . selected ) . to . be . true ;
129- expect ( options [ 0 ] . selected ) . to . be . false ;
146+ expect ( options [ 2 ] . value ) . to . be . equal ( "2" ) ;
147+ expect ( options [ 2 ] . textContent ) . to . be . equal ( "Paris" ) ;
148+ expect ( options [ 2 ] . selected ) . to . be . true ;
149+ expect ( options [ 1 ] . selected ) . to . be . false ;
130150 } ) ;
131151
132152 it ( "should contain the value" , ( done ) => {
0 commit comments