mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 01:10:14 +01:00
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import React from 'react';
|
|||
import '@testing-library/jest-dom/extend-expect';
|
|||
import { render, fireEvent } from 'test/layout-test-utils';
|
|||
import ConversationModeSwitch from './ConversationModeSwitch';
|
|||
import { RecoilRoot } from 'recoil';
|
|||
|
|||
describe('ConversationModeSwitch', () => {
|
|||
/**
|
|||
* Mock function to set the auto-send-text state.
|
|||
*/
|
|||
let mockSetConversationMode: jest.Mock<void, [boolean]> | ((value: boolean) => void) | undefined;
|
|||
|
|||
beforeEach(() => {
|
|||
mockSetConversationMode = jest.fn();
|
|||
});
|
|||
|
|||
it('renders correctly', () => {
|
|||
const { getByTestId } = render(
|
|||
<RecoilRoot>
|
|||
<ConversationModeSwitch />
|
|||
</RecoilRoot>,
|
|||
);
|
|||
|
|||
expect(getByTestId('ConversationMode')).toBeInTheDocument();
|
|||
});
|
|||
|
|||
it('calls onCheckedChange when the switch is toggled', () => {
|
|||
const { getByTestId } = render(
|
|||
<RecoilRoot>
|
|||
<ConversationModeSwitch onCheckedChange={mockSetConversationMode} />
|
|||
</RecoilRoot>,
|
|||
);
|
|||
const switchElement = getByTestId('ConversationMode');
|
|||
fireEvent.click(switchElement);
|
|||
|
|||
expect(mockSetConversationMode).toHaveBeenCalledWith(true);
|
|||
});
|
|||
});
|