@@ -63,24 +63,38 @@ describe("DxcSelectComponent tests", () => {
63
63
onChange : {
64
64
emit : changeMock ,
65
65
} as any ,
66
- value : "1"
66
+ value : "1" ,
67
67
} ,
68
68
imports : [ DxcSelectModule ] ,
69
69
excludeComponentDeclaration : true ,
70
70
} ) ;
71
71
expect ( dxcSelect . getByText ( "Select label" ) ) ;
72
72
expect ( dxcSelect . getByText ( "Helper Text" ) ) ;
73
- expect ( ( ) => dxcSelect . getByText ( "Choose an option" ) ) . toThrow ( ) ;
74
- fireEvent . click ( dxcSelect . getByRole ( 'combobox' ) ) ;
75
- expect ( ( screen . getAllByText ( 'label1' ) [ 1 ] . getAttribute ( "aria-selected" ) ) ) . toBe ( "true" ) ;
73
+ expect ( dxcSelect . getByText ( "label1" ) ) ;
74
+ fireEvent . click ( dxcSelect . getByRole ( "combobox" ) ) ;
75
+ expect ( screen . getAllByText ( "label1" ) [ 1 ] . getAttribute ( "aria-selected" ) ) . toBe (
76
+ "true"
77
+ ) ;
76
78
fireEvent . click ( screen . getByText ( "aida" ) ) ;
77
- expect ( changeMock ) . toHaveBeenCalledWith ( { value : "10" , error : null } ) ;
78
- expect ( ( screen . getAllByText ( 'label1' ) [ 1 ] . getAttribute ( "aria-selected" ) ) ) . toBe ( "true" ) ;
79
- expect ( ( screen . getAllByText ( 'aida' ) [ 0 ] . getAttribute ( "aria-selected" ) ) ) . toBe ( "false" ) ;
80
- expect ( ( screen . getAllByText ( 'label2' ) [ 0 ] . getAttribute ( "aria-selected" ) ) ) . toBe ( "false" ) ;
81
- expect ( ( screen . getAllByText ( 'label6' ) [ 0 ] . getAttribute ( "aria-selected" ) ) ) . toBe ( "false" ) ;
82
- expect ( ( screen . getAllByText ( 'label9' ) [ 0 ] . getAttribute ( "aria-selected" ) ) ) . toBe ( "false" ) ;
83
- expect ( ( screen . getAllByText ( 'pepe' ) [ 0 ] . getAttribute ( "aria-selected" ) ) ) . toBe ( "false" ) ;
79
+ expect ( changeMock ) . toHaveBeenCalledWith ( { value : "10" , error : null } ) ;
80
+ expect ( screen . getAllByText ( "label1" ) [ 1 ] . getAttribute ( "aria-selected" ) ) . toBe (
81
+ "true"
82
+ ) ;
83
+ expect ( screen . getAllByText ( "aida" ) [ 0 ] . getAttribute ( "aria-selected" ) ) . toBe (
84
+ "false"
85
+ ) ;
86
+ expect ( screen . getAllByText ( "label2" ) [ 0 ] . getAttribute ( "aria-selected" ) ) . toBe (
87
+ "false"
88
+ ) ;
89
+ expect ( screen . getAllByText ( "label6" ) [ 0 ] . getAttribute ( "aria-selected" ) ) . toBe (
90
+ "false"
91
+ ) ;
92
+ expect ( screen . getAllByText ( "label9" ) [ 0 ] . getAttribute ( "aria-selected" ) ) . toBe (
93
+ "false"
94
+ ) ;
95
+ expect ( screen . getAllByText ( "pepe" ) [ 0 ] . getAttribute ( "aria-selected" ) ) . toBe (
96
+ "false"
97
+ ) ;
84
98
} ) ;
85
99
86
100
test ( "dxc-select single uncontrolled functionality" , async ( ) => {
@@ -107,27 +121,50 @@ describe("DxcSelectComponent tests", () => {
107
121
} ) ;
108
122
expect ( dxcSelect . getByText ( "Select label" ) ) ;
109
123
expect ( dxcSelect . getByText ( "Helper Text" ) ) ;
110
- dxcSelect . getByText ( "Choose an option" )
111
- fireEvent . click ( dxcSelect . getByRole ( ' combobox' ) ) ;
124
+ dxcSelect . getByText ( "Choose an option" ) ;
125
+ fireEvent . click ( dxcSelect . getByRole ( " combobox" ) ) ;
112
126
fireEvent . click ( screen . getByText ( "aida" ) ) ;
113
- expect ( changeMock ) . toHaveBeenCalledWith ( { value : "10" , error : null } ) ;
114
- expect ( ( screen . getAllByText ( 'aida' ) [ 1 ] . getAttribute ( "aria-selected" ) ) ) . toBe ( "true" ) ;
115
- expect ( ( screen . getAllByText ( 'label1' ) [ 0 ] . getAttribute ( "aria-selected" ) ) ) . toBe ( "false" ) ;
116
- expect ( ( screen . getAllByText ( 'label2' ) [ 0 ] . getAttribute ( "aria-selected" ) ) ) . toBe ( "false" ) ;
117
- expect ( ( screen . getAllByText ( 'label6' ) [ 0 ] . getAttribute ( "aria-selected" ) ) ) . toBe ( "false" ) ;
118
- expect ( ( screen . getAllByText ( 'label9' ) [ 0 ] . getAttribute ( "aria-selected" ) ) ) . toBe ( "false" ) ;
119
- expect ( ( screen . getAllByText ( 'pepe' ) [ 0 ] . getAttribute ( "aria-selected" ) ) ) . toBe ( "false" ) ;
127
+ expect ( changeMock ) . toHaveBeenCalledWith ( { value : "10" , error : null } ) ;
128
+ expect ( screen . getAllByText ( "aida" ) [ 1 ] . getAttribute ( "aria-selected" ) ) . toBe (
129
+ "true"
130
+ ) ;
131
+ expect ( screen . getAllByText ( "label1" ) [ 0 ] . getAttribute ( "aria-selected" ) ) . toBe (
132
+ "false"
133
+ ) ;
134
+ expect ( screen . getAllByText ( "label2" ) [ 0 ] . getAttribute ( "aria-selected" ) ) . toBe (
135
+ "false"
136
+ ) ;
137
+ expect ( screen . getAllByText ( "label6" ) [ 0 ] . getAttribute ( "aria-selected" ) ) . toBe (
138
+ "false"
139
+ ) ;
140
+ expect ( screen . getAllByText ( "label9" ) [ 0 ] . getAttribute ( "aria-selected" ) ) . toBe (
141
+ "false"
142
+ ) ;
143
+ expect ( screen . getAllByText ( "pepe" ) [ 0 ] . getAttribute ( "aria-selected" ) ) . toBe (
144
+ "false"
145
+ ) ;
120
146
fireEvent . click ( screen . getByText ( "pepe" ) ) ;
121
- expect ( changeMock ) . toHaveBeenCalledWith ( { value : "11" , error : null } ) ;
122
- expect ( ( screen . getAllByText ( 'pepe' ) [ 1 ] . getAttribute ( "aria-selected" ) ) ) . toBe ( "true" ) ;
123
- expect ( ( screen . getAllByText ( 'label1' ) [ 0 ] . getAttribute ( "aria-selected" ) ) ) . toBe ( "false" ) ;
124
- expect ( ( screen . getAllByText ( 'label2' ) [ 0 ] . getAttribute ( "aria-selected" ) ) ) . toBe ( "false" ) ;
125
- expect ( ( screen . getAllByText ( 'label6' ) [ 0 ] . getAttribute ( "aria-selected" ) ) ) . toBe ( "false" ) ;
126
- expect ( ( screen . getAllByText ( 'label9' ) [ 0 ] . getAttribute ( "aria-selected" ) ) ) . toBe ( "false" ) ;
127
- expect ( ( screen . getAllByText ( 'aida' ) [ 0 ] . getAttribute ( "aria-selected" ) ) ) . toBe ( "false" ) ;
147
+ expect ( changeMock ) . toHaveBeenCalledWith ( { value : "11" , error : null } ) ;
148
+ expect ( screen . getAllByText ( "pepe" ) [ 1 ] . getAttribute ( "aria-selected" ) ) . toBe (
149
+ "true"
150
+ ) ;
151
+ expect ( screen . getAllByText ( "label1" ) [ 0 ] . getAttribute ( "aria-selected" ) ) . toBe (
152
+ "false"
153
+ ) ;
154
+ expect ( screen . getAllByText ( "label2" ) [ 0 ] . getAttribute ( "aria-selected" ) ) . toBe (
155
+ "false"
156
+ ) ;
157
+ expect ( screen . getAllByText ( "label6" ) [ 0 ] . getAttribute ( "aria-selected" ) ) . toBe (
158
+ "false"
159
+ ) ;
160
+ expect ( screen . getAllByText ( "label9" ) [ 0 ] . getAttribute ( "aria-selected" ) ) . toBe (
161
+ "false"
162
+ ) ;
163
+ expect ( screen . getAllByText ( "aida" ) [ 0 ] . getAttribute ( "aria-selected" ) ) . toBe (
164
+ "false"
165
+ ) ;
128
166
} ) ;
129
167
130
-
131
168
test ( "should render optional error" , async ( ) => {
132
169
const array1 : Option [ ] = [
133
170
{ label : "label1" , value : "1" } ,
@@ -155,7 +192,9 @@ describe("DxcSelectComponent tests", () => {
155
192
expect ( dxcSelect . getByText ( "Helper Text" ) ) ;
156
193
fireEvent . click ( dxcSelect . getByText ( "Choose an option" ) ) ;
157
194
fireEvent . focusOut ( dxcSelect . getByText ( "Choose an option" ) ) ;
158
- expect ( onBlur ) . toHaveBeenCalledWith ( { value : "" , error : "This field is required. Please, enter a value." } ) ;
159
-
195
+ expect ( onBlur ) . toHaveBeenCalledWith ( {
196
+ value : "" ,
197
+ error : "This field is required. Please, enter a value." ,
198
+ } ) ;
160
199
} ) ;
161
200
} ) ;
0 commit comments