mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-21 19:40:34 +00:00
3fcfb12749
Both folds on the settings page opened with the same summary line and turning chevron. FoldSummary now draws it and each fold passes its own label; the Google fold keeps its status pill.
36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { fireEvent, render, screen } from '../../../tests/helpers/render';
|
|
import FoldSummary from './FoldSummary';
|
|
|
|
describe('FoldSummary', () => {
|
|
it('heads the fold with a turning chevron and its own label', () => {
|
|
const { container } = render(
|
|
<details className="group">
|
|
<FoldSummary>
|
|
<span>More</span>
|
|
</FoldSummary>
|
|
<p>inside</p>
|
|
</details>
|
|
);
|
|
const summary = container.querySelector('summary') as HTMLElement;
|
|
expect(summary).toContainElement(screen.getByText('More'));
|
|
const chevron = summary.querySelector('svg') as SVGElement;
|
|
expect(chevron).toHaveAttribute('aria-hidden', 'true');
|
|
expect(chevron.getAttribute('class')).toContain('group-open:rotate-90');
|
|
expect(summary.firstElementChild).toBe(chevron);
|
|
});
|
|
|
|
it('opens and closes the fold it heads', () => {
|
|
const { container } = render(
|
|
<details className="group">
|
|
<FoldSummary>More</FoldSummary>
|
|
<p>inside</p>
|
|
</details>
|
|
);
|
|
const details = container.querySelector('details') as HTMLDetailsElement;
|
|
expect(details.open).toBe(false);
|
|
fireEvent.click(container.querySelector('summary') as HTMLElement);
|
|
expect(details.open).toBe(true);
|
|
});
|
|
});
|