@@ -155,12 +155,12 @@ describe('New Input Component', () => {
155
155
expect ( results ) . toHaveNoViolations ( ) ;
156
156
} ) ;
157
157
158
- it ( 'Should call onIconClick when user click on icon' , async ( ) => {
158
+ it ( 'Should call onLeftIconClick when user click on left icon' , async ( ) => {
159
159
const onIconClick = jest . fn ( ) ;
160
160
const { container, getByRole } = renderProvider (
161
161
< Input
162
162
{ ...commonProps }
163
- icon = { { icon : 'UNICORN' , altText : 'Open Info' , onClick : onIconClick } }
163
+ leftIcon = { { icon : 'UNICORN' , altText : 'Open Info' , onClick : onIconClick } }
164
164
placeholder = { 'placeholder' }
165
165
/>
166
166
) ;
@@ -175,6 +175,26 @@ describe('New Input Component', () => {
175
175
expect ( results ) . toHaveNoViolations ( ) ;
176
176
} ) ;
177
177
178
+ it ( 'Should call onRightIconClick when user click on right icon' , async ( ) => {
179
+ const onIconClick = jest . fn ( ) ;
180
+ const { container, getByRole } = renderProvider (
181
+ < Input
182
+ { ...commonProps }
183
+ placeholder = { 'placeholder' }
184
+ rightIcon = { { icon : 'UNICORN' , altText : 'Open Info' , onClick : onIconClick } }
185
+ />
186
+ ) ;
187
+
188
+ const triggerButton = getByRole ( 'button' , { name : 'Open Info' } ) ;
189
+ fireEvent . click ( triggerButton ) ;
190
+ expect ( onIconClick ) . toHaveBeenCalled ( ) ;
191
+
192
+ // A11Y and w3c validator
193
+ const results = await axe ( container ) ;
194
+ expect ( container ) . toHTMLValidate ( ) ;
195
+ expect ( results ) . toHaveNoViolations ( ) ;
196
+ } ) ;
197
+
178
198
it ( 'Should be autoformated the text with mask' , async ( ) => {
179
199
const onChange = jest . fn ( ) ;
180
200
const { container, getByRole } = renderProvider (
@@ -348,12 +368,36 @@ describe('New Input Component', () => {
348
368
expect ( results ) . toHaveNoViolations ( ) ;
349
369
} ) ;
350
370
351
- it ( 'Should show icon as img instead of as button' , async ( ) => {
371
+ it ( 'Should show left icon as img instead of as button' , async ( ) => {
372
+ const iconClick = jest . fn ( ) ;
373
+ const { container, getByRole } = renderProvider (
374
+ < Input
375
+ { ...commonProps }
376
+ leftIcon = { { icon : 'UNICORN' , altText : 'Open Info' , onClick : iconClick } }
377
+ placeholder = { 'placeholder' }
378
+ />
379
+ ) ;
380
+
381
+ const triggerButton = getByRole ( 'button' , { name : 'Open Info' } ) ;
382
+ expect ( triggerButton ) . toBeInTheDocument ( ) ;
383
+
384
+ fireEvent . click ( triggerButton ) ;
385
+
386
+ expect ( iconClick ) . toHaveBeenCalled ( ) ;
387
+
388
+ // A11Y and w3c validator
389
+ const results = await axe ( container ) ;
390
+ expect ( container ) . toHTMLValidate ( ) ;
391
+ expect ( results ) . toHaveNoViolations ( ) ;
392
+ } ) ;
393
+
394
+ it ( 'Should show right icon as img instead of as button' , async ( ) => {
395
+ const iconClick = jest . fn ( ) ;
352
396
const { container, getByRole } = renderProvider (
353
397
< Input
354
398
{ ...commonProps }
355
- icon = { { icon : 'UNICORN' , altText : 'Open Info' } }
356
399
placeholder = { 'placeholder' }
400
+ rightIcon = { { icon : 'UNICORN' , altText : 'Open Info' , onClick : iconClick } }
357
401
/>
358
402
) ;
359
403
0 commit comments