Skip to content

Commit

Permalink
combine tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Barsnes committed Jun 11, 2024
1 parent af72c7d commit 0f87e3a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 84 deletions.
31 changes: 27 additions & 4 deletions packages/react/src/components/Accordion/Accordion.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ const TestComponent = ({
return (
<Accordion>
<Accordion.Item {...rest}>
<Accordion.Header level={3}>
Accordion Header Title Text
</Accordion.Header>
<Accordion.Header>Accordion Header Title Text</Accordion.Header>
<Accordion.Content>
The fantastic accordion content text
</Accordion.Content>
Expand All @@ -31,10 +29,10 @@ describe('Accordion', () => {
expect(
screen.getByRole('heading', {
name: 'Accordion Header Title Text',
level: 3,
}),
).toBeInTheDocument();
expect(screen.getByText('The fantastic accordion content text'));
expect(screen.getByText('Accordion Header Title Text'));
expect(accordionExpandButton).toHaveAttribute('aria-expanded', 'false');
});

Expand All @@ -43,6 +41,31 @@ describe('Accordion', () => {
const accordionExpandButton = screen.getByRole('button');
expect(accordionExpandButton).toHaveAttribute('aria-expanded', 'true');
});

test('Should be able to set defaultOpen on uncontrolled', () => {
render(<TestComponent defaultOpen />);

const accordionExpandButton = screen.getByRole('button');
expect(accordionExpandButton).toHaveAttribute('aria-expanded', 'true');
});

test('should be able to render AccordionItem as controlled', () => {
render(<TestComponent open />);

const accordionExpandButton = screen.getByRole('button');
expect(accordionExpandButton).toHaveAttribute('aria-expanded', 'true');
});

test('should render heading as level 1 by default', () => {
render(<TestComponent />);

expect(
screen.getByRole('heading', {
name: 'Accordion Header Title Text',
level: 1,
}),
);
});
});

describe('Accordion Accessibility', () => {
Expand Down
19 changes: 0 additions & 19 deletions packages/react/src/components/Accordion/AccordionContent.test.tsx

This file was deleted.

5 changes: 4 additions & 1 deletion packages/react/src/components/Accordion/AccordionHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import { Paragraph, Heading } from '..';
import { AccordionItemContext } from './AccordionItem';

export type AccordionHeaderProps = {
/** Heading level. Use this to make sure the heading is correct according to you page heading levels */
/**
* Heading level. Use this to make sure the heading is correct according to you page heading levels
* @default 1
*/
level?: 1 | 2 | 3 | 4 | 5 | 6;
/** Handle when clicked on header */
onHeaderClick?: MouseEventHandler<HTMLButtonElement> | undefined;
Expand Down
60 changes: 0 additions & 60 deletions packages/react/src/components/Accordion/AccordionItem.test.tsx

This file was deleted.

0 comments on commit 0f87e3a

Please sign in to comment.