Files
TREK/client/src/pages/admin/FoldSummary.test.tsx
T
Maurice 3fcfb12749 refactor(admin): share the fold head of the Google options and the TREK API card
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.
2026-10-09 16:15:49 +02:00

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);
});
});