11import React from 'react' ;
22import { render , screen , fireEvent } from '@testing-library/react' ;
3- import { vi } from 'vitest' ;
43import { Button } from './button.js' ;
4+ import { vi } from 'vitest' ;
55
66describe ( 'Button' , ( ) => {
77 it ( 'renders children correctly' , ( ) => {
@@ -56,7 +56,7 @@ describe('Button', () => {
5656 } ) ;
5757
5858 it ( 'renders icon correctly' , ( ) => {
59- const icon = < span data-testid = "test-icon" role = "img" aria-label = "Rocket" > 🚀</ span > ;
59+ const icon = < span data-testid = "test-icon" > 🚀</ span > ;
6060 render ( < Button icon = { icon } > Click me</ Button > ) ;
6161 expect ( screen . getByTestId ( 'test-icon' ) ) . toBeInTheDocument ( ) ;
6262 } ) ;
@@ -68,7 +68,7 @@ describe('Button', () => {
6868 } ) ;
6969
7070 it ( 'hides icons when in loading state' , ( ) => {
71- const icon = < span data-testid = "test-icon" role = "img" aria-label = "Rocket" > 🚀</ span > ;
71+ const icon = < span data-testid = "test-icon" > 🚀</ span > ;
7272 render ( < Button loading icon = { icon } > Click me</ Button > ) ;
7373 expect ( screen . queryByTestId ( 'test-icon' ) ) . not . toBeInTheDocument ( ) ;
7474 } ) ;
@@ -88,22 +88,4 @@ describe('Button', () => {
8888 rerender ( < Button type = "reset" > Button</ Button > ) ;
8989 expect ( screen . getByRole ( 'button' ) ) . toHaveAttribute ( 'type' , 'reset' ) ;
9090 } ) ;
91-
92- it ( 'applies multiple props correctly when combined' , ( ) => {
93- render (
94- < Button
95- variant = "danger"
96- size = "large"
97- data-testid = "combined-button"
98- >
99- Delete Item
100- </ Button >
101- ) ;
102-
103- const button = screen . getByTestId ( 'combined-button' ) ;
104- expect ( button ) . toHaveClass ( 'danger' ) ;
105- expect ( button ) . toHaveClass ( 'large' ) ;
106- expect ( button ) . toHaveAttribute ( 'type' , 'button' ) ; // default type
107- expect ( screen . getByText ( 'Delete Item' ) ) . toBeInTheDocument ( ) ;
108- } ) ;
10991} ) ;
0 commit comments