mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 09:20:15 +01:00
test: add unit tests for ClearChatsButton and ThemeSelector components
This commit is contained in:
parent
931a89204c
commit
8c536cb93c
3 changed files with 71 additions and 1 deletions
|
|
@ -0,0 +1,31 @@
|
|||
import React from 'react';
|
||||
import { render, fireEvent } from '@testing-library/react';
|
||||
import '@testing-library/jest-dom/extend-expect';
|
||||
import { ThemeSelector } from './General';
|
||||
|
||||
describe('ThemeSelector', () => {
|
||||
let mockOnChange;
|
||||
|
||||
beforeEach(() => {
|
||||
mockOnChange = jest.fn();
|
||||
});
|
||||
|
||||
it('renders correctly', () => {
|
||||
const { getByText, getByDisplayValue } = render(
|
||||
<ThemeSelector theme="system" onChange={mockOnChange} />
|
||||
);
|
||||
|
||||
expect(getByText('Theme')).toBeInTheDocument();
|
||||
expect(getByDisplayValue('System')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('calls onChange when the select value changes', () => {
|
||||
const { getByDisplayValue } = render(
|
||||
<ThemeSelector theme="system" onChange={mockOnChange} />
|
||||
);
|
||||
|
||||
fireEvent.change(getByDisplayValue('System'), { target: { value: 'dark' } });
|
||||
|
||||
expect(mockOnChange).toHaveBeenCalledWith('dark');
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue