tests
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import React from 'react';
|
||||
import { render, screen, fireEvent } from '@testing-library/react';
|
||||
import Search from '../src/components/home/Search.jsx';
|
||||
|
||||
describe('Search Component', () => {
|
||||
it('should render the Search button', () => {
|
||||
render(<Search search={() => {}} item="testItem" />);
|
||||
const searchButton = screen.getByText(/find/i);
|
||||
expect(searchButton).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should call the search function with the correct item when clicked', () => {
|
||||
const mockSearch = jest.fn();
|
||||
const item = 'testItem';
|
||||
|
||||
render(<Search search={mockSearch} item={item} />);
|
||||
|
||||
const searchButton = screen.getByText(/find/i);
|
||||
fireEvent.click(searchButton);
|
||||
|
||||
expect(mockSearch).toHaveBeenCalledWith(item);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user