mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-23 18:56:12 +01:00
* style: update new icon and NavLinks scale * style: new username update * refactor(Dropdown); style: general settings * style(Dropdown); adjust theme * style: dropdown and settings text * fix(Dropdown) system theme not working * style: topbar sticky; fix: general's menu settings transparent with light theme * fix(SubmitButton) stop generate button * fix: user_provided dialog for new dropdown * fix: TS error 'display' * fix(EditPresetDialog): for new dropdown * style: added green send button * converted textchat in tsx * style(SubmitButton): tooltip * test: fixed ThemeSelector and LangSelector * removed transition-opacity * fix all tests * removed empty cn call * chore: Update General.tsx to add Arabic option --------- Co-authored-by: Danny Avila <110412045+danny-avila@users.noreply.github.com>
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
import 'test/matchMedia.mock';
|
|
import React from 'react';
|
|
import { render, fireEvent } from '@testing-library/react';
|
|
import '@testing-library/jest-dom/extend-expect';
|
|
import { LangSelector } from './General';
|
|
import { RecoilRoot } from 'recoil';
|
|
|
|
describe('LangSelector', () => {
|
|
let mockOnChange;
|
|
|
|
beforeEach(() => {
|
|
mockOnChange = jest.fn();
|
|
});
|
|
|
|
it('renders correctly', () => {
|
|
const { getByText } = render(
|
|
<RecoilRoot>
|
|
<LangSelector langcode="en-US" onChange={mockOnChange} />
|
|
</RecoilRoot>,
|
|
);
|
|
|
|
expect(getByText('Language')).toBeInTheDocument();
|
|
expect(getByText('English')).toBeInTheDocument();
|
|
});
|
|
|
|
it('calls onChange when the select value changes', async () => {
|
|
const { getByText, getByTestId } = render(
|
|
<RecoilRoot>
|
|
<LangSelector langcode="en-US" onChange={mockOnChange} />
|
|
</RecoilRoot>,
|
|
);
|
|
|
|
expect(getByText('English')).toBeInTheDocument();
|
|
|
|
// Find the dropdown button by data-testid
|
|
const dropdownButton = getByTestId('dropdown-menu');
|
|
|
|
// Open the dropdown
|
|
fireEvent.click(dropdownButton);
|
|
|
|
// Find the option by text and click it
|
|
const darkOption = getByText('Italiano');
|
|
fireEvent.click(darkOption);
|
|
|
|
// Ensure that the onChange is called with the expected value after a short delay
|
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
});
|
|
});
|