mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
24 lines
836 B
TypeScript
24 lines
836 B
TypeScript
import { render } from '@testing-library/svelte';
|
|
import SettingSwitch from './setting-switch.svelte';
|
|
|
|
describe('SettingSwitch component', () => {
|
|
it('links switch and subtitle ids on the switch', () => {
|
|
const { getByText } = render(SettingSwitch, {
|
|
props: {
|
|
title: 'Enable feature',
|
|
subtitle: 'Controls the feature state.',
|
|
},
|
|
});
|
|
|
|
const label = getByText('Enable feature') as HTMLLabelElement;
|
|
const subtitle = getByText('Controls the feature state.');
|
|
const subtitleId = subtitle.getAttribute('id');
|
|
const switchElement = document.querySelector(`#${label.htmlFor}`);
|
|
|
|
expect(subtitleId).not.toBeNull();
|
|
expect(label.htmlFor).not.toBe('');
|
|
expect(switchElement).not.toBeNull();
|
|
expect(switchElement?.getAttribute('aria-describedby')).toBe(subtitleId);
|
|
});
|
|
});
|