mirror of
https://github.com/immich-app/immich.git
synced 2025-12-20 01:11:46 +03:00
fix(web): clear combobox value when selectedOption is undefined (#14334)
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { getIntersectionObserverMock } from '$lib/__mocks__/intersection-observer.mock';
|
||||
import { getVisualViewportMock } from '$lib/__mocks__/visual-viewport.mock';
|
||||
import Combobox from '$lib/components/shared-components/combobox.svelte';
|
||||
import { render, screen } from '@testing-library/svelte';
|
||||
|
||||
describe('Combobox component', () => {
|
||||
beforeAll(() => {
|
||||
vi.stubGlobal('IntersectionObserver', getIntersectionObserverMock());
|
||||
vi.stubGlobal('visualViewport', getVisualViewportMock());
|
||||
});
|
||||
|
||||
it('shows selected option', () => {
|
||||
render(Combobox, {
|
||||
label: 'test',
|
||||
selectedOption: { label: 'option-1', value: 'option-1' },
|
||||
});
|
||||
|
||||
expect(screen.getByRole('combobox')).toHaveValue('option-1');
|
||||
});
|
||||
|
||||
it('clears the selected option when set to undefined', async () => {
|
||||
const { rerender } = render(Combobox, {
|
||||
label: 'test',
|
||||
selectedOption: { label: 'option-1', value: 'option-1' },
|
||||
});
|
||||
|
||||
await rerender({ selectedOption: undefined });
|
||||
expect(screen.getByRole('combobox')).toHaveValue('');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user