-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
140 changed files
with
5,366 additions
and
5,944 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
services/ui-src/src/components/accordions/InstructionsAccordion.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { render, screen } from "@testing-library/react"; | ||
import userEvent from "@testing-library/user-event"; | ||
// components | ||
import { InstructionsAccordion } from "components"; | ||
// utils | ||
import { testA11y } from "utils/testing/commonTests"; | ||
|
||
export const mockAccordion = { | ||
buttonLabel: "Instructions", | ||
intro: [ | ||
{ | ||
type: "text", | ||
as: "span", | ||
content: "<b>Bold Instructions</b>", | ||
}, | ||
{ | ||
type: "text", | ||
as: "span", | ||
content: "More instructions", | ||
}, | ||
], | ||
list: [`List Item 1`, "List Item 2", `List Item 3`], | ||
text: "Additional Text", | ||
}; | ||
|
||
const accordionComponent = <InstructionsAccordion verbiage={mockAccordion} />; | ||
|
||
describe("<InstructionsAccordion />", () => { | ||
beforeEach(() => { | ||
render(accordionComponent); | ||
}); | ||
|
||
test("Accordion is visible", () => { | ||
expect(screen.getByText(mockAccordion.buttonLabel)).toBeVisible(); | ||
}); | ||
|
||
test("Accordion default closed state only shows the question", () => { | ||
expect(screen.getByText(mockAccordion.buttonLabel)).toBeVisible(); | ||
expect(screen.getByText(mockAccordion.text)).not.toBeVisible(); | ||
}); | ||
|
||
test("Accordion should show answer on click", async () => { | ||
const accordionQuestion = screen.getByText(mockAccordion.buttonLabel); | ||
expect(accordionQuestion).toBeVisible(); | ||
expect(screen.getByText(mockAccordion.text)).not.toBeVisible(); | ||
await userEvent.click(accordionQuestion); | ||
expect(accordionQuestion).toBeVisible(); | ||
expect(screen.getByText(mockAccordion.text)).toBeVisible(); | ||
}); | ||
|
||
testA11y(accordionComponent); | ||
}); |
41 changes: 14 additions & 27 deletions
41
services/ui-src/src/components/accordions/TemplateCardAccordion.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,43 @@ | ||
import { render, screen } from "@testing-library/react"; | ||
import { axe } from "jest-axe"; | ||
import userEvent from "@testing-library/user-event"; | ||
// utils | ||
import { RouterWrappedComponent } from "utils/testing/setupJest"; | ||
// components | ||
import { TemplateCardAccordion } from "components"; | ||
// utils | ||
import { RouterWrappedComponent } from "utils/testing/setupJest"; | ||
import { testA11y } from "utils/testing/commonTests"; | ||
// verbiage | ||
import verbiage from "verbiage/pages/home"; | ||
|
||
const { buttonLabel, text: accordionText } = verbiage.cards.MCPAR.accordion; | ||
|
||
const accordionComponent = ( | ||
<RouterWrappedComponent> | ||
<TemplateCardAccordion verbiage={verbiage.cards.MCPAR.accordion} /> | ||
</RouterWrappedComponent> | ||
); | ||
|
||
describe("Test TemplateCardAccordion", () => { | ||
describe("<TemplateCardAccordion />", () => { | ||
beforeEach(() => { | ||
render(accordionComponent); | ||
}); | ||
|
||
test("Accordion is visible", () => { | ||
expect( | ||
screen.getByText(verbiage.cards.MCPAR.accordion.buttonLabel) | ||
).toBeVisible(); | ||
expect(screen.getByText(buttonLabel)).toBeVisible(); | ||
}); | ||
|
||
test("Accordion default closed state only shows the question", () => { | ||
expect( | ||
screen.getByText(verbiage.cards.MCPAR.accordion.buttonLabel) | ||
).toBeVisible(); | ||
expect( | ||
screen.getByText(verbiage.cards.MCPAR.accordion.text) | ||
).not.toBeVisible(); | ||
expect(screen.getByText(buttonLabel)).toBeVisible(); | ||
expect(screen.getByText(accordionText)).not.toBeVisible(); | ||
}); | ||
|
||
test("Accordion should show answer on click", async () => { | ||
const accordionQuestion = screen.getByText( | ||
verbiage.cards.MCPAR.accordion.buttonLabel | ||
); | ||
const accordionQuestion = screen.getByText(buttonLabel); | ||
expect(accordionQuestion).toBeVisible(); | ||
expect( | ||
screen.getByText(verbiage.cards.MCPAR.accordion.text) | ||
).not.toBeVisible(); | ||
expect(screen.getByText(accordionText)).not.toBeVisible(); | ||
await userEvent.click(accordionQuestion); | ||
expect(accordionQuestion).toBeVisible(); | ||
expect(screen.getByText(verbiage.cards.MCPAR.accordion.text)).toBeVisible(); | ||
expect(screen.getByText(accordionText)).toBeVisible(); | ||
}); | ||
}); | ||
|
||
describe("Test TemplateCardAccordion accessibility", () => { | ||
it("Should not have basic accessibility issues", async () => { | ||
const { container } = render(accordionComponent); | ||
const results = await axe(container); | ||
expect(results).toHaveNoViolations(); | ||
}); | ||
testA11y(accordionComponent); | ||
}); |
2 changes: 1 addition & 1 deletion
2
services/ui-src/src/components/accordions/TemplateCardAccordion.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.