Skip to content

Commit

Permalink
test(accordion): ✅ added correct snapshot testing with baseId
Browse files Browse the repository at this point in the history
  • Loading branch information
navin-moorthy committed Oct 16, 2020
1 parent 43403fc commit e715ec3
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/accordion/__tests__/Accordion.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ const AccordionComponent = (props: any) => {
};

describe("Accordion", () => {
it("should render correctly", () => {
const { asFragment } = render(<AccordionComponent baseId="accordion" />);

expect(asFragment()).toMatchSnapshot();
});

it("Accordion should have proper keyboard navigation", () => {
const { getByText: text } = render(<AccordionComponent />);

Expand Down
70 changes: 70 additions & 0 deletions src/accordion/__tests__/__snapshots__/Accordion.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Accordion should render correctly 1`] = `
<DocumentFragment>
<div
id="accordion"
>
<h3>
<button
aria-controls="accordion-3"
aria-expanded="false"
id="accordion-1"
tabindex="0"
type="button"
>
Trigger 1
</button>
</h3>
<div
aria-labelledby="accordion-1"
hidden=""
id="accordion-3"
role="region"
style="display: none;"
>
Panel 1
</div>
<h3>
<button
aria-controls="accordion-6"
aria-expanded="false"
id="accordion-2"
tabindex="0"
type="button"
>
Trigger 2
</button>
</h3>
<div
aria-labelledby="accordion-2"
hidden=""
id="accordion-6"
role="region"
style="display: none;"
>
Panel 2
</div>
<h3>
<button
aria-controls="accordion-9"
aria-expanded="false"
id="accordion-7"
tabindex="0"
type="button"
>
Trigger 3
</button>
</h3>
<div
aria-labelledby="accordion-7"
hidden=""
id="accordion-9"
role="region"
style="display: none;"
>
Panel 3
</div>
</div>
</DocumentFragment>
`;

0 comments on commit e715ec3

Please sign in to comment.