@@ -63,24 +63,38 @@ describe("DxcSelectComponent tests", () => {
6363 onChange : {
6464 emit : changeMock ,
6565 } as any ,
66- value : "1"
66+ value : "1" ,
6767 } ,
6868 imports : [ DxcSelectModule ] ,
6969 excludeComponentDeclaration : true ,
7070 } ) ;
7171 expect ( dxcSelect . getByText ( "Select label" ) ) ;
7272 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+ ) ;
7678 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+ ) ;
8498 } ) ;
8599
86100 test ( "dxc-select single uncontrolled functionality" , async ( ) => {
@@ -107,27 +121,50 @@ describe("DxcSelectComponent tests", () => {
107121 } ) ;
108122 expect ( dxcSelect . getByText ( "Select label" ) ) ;
109123 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" ) ) ;
112126 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+ ) ;
120146 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+ ) ;
128166 } ) ;
129167
130-
131168 test ( "should render optional error" , async ( ) => {
132169 const array1 : Option [ ] = [
133170 { label : "label1" , value : "1" } ,
@@ -155,7 +192,9 @@ describe("DxcSelectComponent tests", () => {
155192 expect ( dxcSelect . getByText ( "Helper Text" ) ) ;
156193 fireEvent . click ( dxcSelect . getByText ( "Choose an option" ) ) ;
157194 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+ } ) ;
160199 } ) ;
161200} ) ;
0 commit comments