@@ -20,6 +20,7 @@ describe("fieldSelectEx.vue", () => {
20
20
label : "Cities" ,
21
21
model : "city" ,
22
22
multiSelect : false ,
23
+ required : false ,
23
24
values : [
24
25
"London" ,
25
26
"Paris" ,
@@ -47,13 +48,19 @@ describe("fieldSelectEx.vue", () => {
47
48
48
49
it ( "should contain option elements" , ( ) => {
49
50
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>
51
52
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 ;
55
56
} ) ;
56
57
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
+
57
64
it ( "should contain the value" , ( done ) => {
58
65
vm . $nextTick ( ( ) => {
59
66
expect ( input . value ) . to . be . equal ( "Paris" ) ;
@@ -89,10 +96,23 @@ describe("fieldSelectEx.vue", () => {
89
96
90
97
} ) ;
91
98
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
+
92
109
it ( "should not be multiple" , ( done ) => {
93
110
schema . multiSelect = true ;
94
111
vm . $nextTick ( ( ) => {
95
112
expect ( input . multiple ) . to . be . true ;
113
+ let options = input . querySelectorAll ( "option" ) ;
114
+ expect ( options . length ) . to . be . equal ( 4 ) ; // no <non selected>
115
+
96
116
done ( ) ;
97
117
} ) ;
98
118
} ) ;
@@ -121,12 +141,12 @@ describe("fieldSelectEx.vue", () => {
121
141
122
142
it ( "should contain option elements" , ( ) => {
123
143
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>
125
145
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 ;
130
150
} ) ;
131
151
132
152
it ( "should contain the value" , ( done ) => {
0 commit comments