-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Unit testing for ArticleCTA component * Unit testing for BasicTextWithImage component * Unit testing for Button component * fixed typos in ImageWithCollapse.stories.js * Unit testing for ImageWithCollapse component * Unit testing for QuoteVerticalLineContent component * Unit testing for ImageVerticalLineContent component * Unit testing for TextContent component * Unit testing for TextWithImage component * updated alt arg value to match unit test query * fix dcterms metadata to better support AA (#1019) * Font Optimization (#1020) * setup google fonts to be served locally * implement fonts using next/font * apply Lato and Notosans variables directly to Modal * remove duplicate main landmark * fix duplicate main landmarks in error pages * added on click test-case for ImageWithCollapse.test * small update to ImageWithCollapse.test --------- Co-authored-by: Jordan Willis <[email protected]> Co-authored-by: Jordan <[email protected]>
- Loading branch information
1 parent
3fbaa54
commit df82ee4
Showing
11 changed files
with
195 additions
and
6 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
components/fragment_renderer/fragment_components/ArticleCTA.test.js
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,16 @@ | ||
import React from "react"; | ||
import { render, screen } from "@testing-library/react"; | ||
import ArticleCTA from "./ArticleCTA"; | ||
import { Default } from "./ArticleCTA.stories.js"; | ||
import { axe, toHaveNoViolations } from "jest-axe"; | ||
|
||
expect.extend(toHaveNoViolations); | ||
|
||
describe("ArticleCTA", () => { | ||
test("renders ArticleCTA component with default props", async () => { | ||
const { container } = render(<ArticleCTA {...Default.args} />); | ||
expect(screen.getByText("This is a body")).toBeInTheDocument(); | ||
const results = await axe(container); | ||
expect(results).toHaveNoViolations(); | ||
}); | ||
}); |
18 changes: 18 additions & 0 deletions
18
components/fragment_renderer/fragment_components/BasicTextWithImage.test.js
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,18 @@ | ||
import React from "react"; | ||
import { render, screen } from "@testing-library/react"; | ||
import BasicTextWithImage from "./BasicTextWithImage"; | ||
import { Default } from "./BasicTextWithImage.stories.js"; | ||
import { axe, toHaveNoViolations } from "jest-axe"; | ||
|
||
expect.extend(toHaveNoViolations); | ||
|
||
describe("BasicTextWithImage", () => { | ||
test("renders BasicTextWithImage component with default props", async () => { | ||
const { container } = render(<BasicTextWithImage {...Default.args} />); | ||
expect(screen.getByAltText("image alt text")).toBeInTheDocument(); | ||
expect(screen.getByText((content) => content.startsWith("Every week"))) | ||
.toBeInTheDocument; | ||
const results = await axe(container); | ||
expect(results).toHaveNoViolations(); | ||
}); | ||
}); |
23 changes: 23 additions & 0 deletions
23
components/fragment_renderer/fragment_components/Button.test.js
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,23 @@ | ||
import React from "react"; | ||
import { render, screen } from "@testing-library/react"; | ||
import Button from "./Button"; | ||
import { Primary } from "./Button.stories.js"; | ||
import { Secondary } from "./Button.stories.js"; | ||
import { axe, toHaveNoViolations } from "jest-axe"; | ||
|
||
expect.extend(toHaveNoViolations); | ||
|
||
describe("Button", () => { | ||
test("renders Button component with Primary props", async () => { | ||
const { container } = render(<Button {...Primary.args} />); | ||
expect(screen.getByText("Primary Button")).toBeInTheDocument(); | ||
const results = await axe(container); | ||
expect(results).toHaveNoViolations(); | ||
}); | ||
test("renders Button component with Secondary props", async () => { | ||
const { container } = render(<Button {...Secondary.args} />); | ||
expect(screen.getByText("Secondary Button")).toBeInTheDocument(); | ||
const results = await axe(container); | ||
expect(results).toHaveNoViolations(); | ||
}); | ||
}); |
21 changes: 21 additions & 0 deletions
21
components/fragment_renderer/fragment_components/ImageVerticalLineContent.test.js
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,21 @@ | ||
import React from "react"; | ||
import { render, screen } from "@testing-library/react"; | ||
import ImageVerticalLineContent from "./ImageVerticalLineContent"; | ||
import { Default } from "./ImageVerticalLineContent.stories.js"; | ||
import { axe, toHaveNoViolations } from "jest-axe"; | ||
|
||
expect.extend(toHaveNoViolations); | ||
|
||
describe("ImageVerticalLineContent", () => { | ||
test("renders ImageVerticalLineContent component with default props", async () => { | ||
const { container } = render( | ||
<ImageVerticalLineContent {...Default.args} /> | ||
); | ||
expect(screen.getByAltText("image alt text")).toBeInTheDocument(); | ||
expect( | ||
screen.getByText((content) => content.startsWith("Every week")) | ||
).toBeInTheDocument(); | ||
const results = await axe(container); | ||
expect(results).toHaveNoViolations(); | ||
}); | ||
}); |
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
42 changes: 42 additions & 0 deletions
42
components/fragment_renderer/fragment_components/ImageWithCollapse.test.js
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,42 @@ | ||
import React from "react"; | ||
import { render, screen } from "@testing-library/react"; | ||
import ImageWithCollapse from "./ImageWithCollapse"; | ||
import { Default } from "./ImageWithCollapse.stories.js"; | ||
import { axe, toHaveNoViolations } from "jest-axe"; | ||
import { userEvent } from "../../../node_modules/@storybook/test/dist/index"; | ||
|
||
expect.extend(toHaveNoViolations); | ||
|
||
describe("ImageWithCollapse", () => { | ||
test("renders ImageWithCollapse component with default props", async () => { | ||
const { container } = render(<ImageWithCollapse {...Default.args} />); | ||
expect(screen.getByAltText("image alt text")).toBeInTheDocument(); | ||
expect( | ||
screen.getByText((content) => content.startsWith("Every")) | ||
).toBeInTheDocument(); | ||
expect( | ||
screen.getByText((content) => content.startsWith("Example Title")) | ||
).toBeInTheDocument(); | ||
const results = await axe(container); | ||
expect(results).toHaveNoViolations(); | ||
}); | ||
|
||
test("on click renders Collapse component with default props", async () => { | ||
const { container } = render(<ImageWithCollapse {...Default.args} />); | ||
const collapse = screen.getByText((content) => | ||
content.startsWith("Example Title") | ||
); | ||
userEvent.click(collapse); | ||
expect( | ||
screen.getByText((content) => content.startsWith("First")) | ||
).toBeInTheDocument(); | ||
expect( | ||
screen.getByText((content) => content.startsWith("Unordered list item 1")) | ||
).toBeInTheDocument(); | ||
expect( | ||
screen.getByText((content) => content.startsWith("Ordered list item 1")) | ||
).toBeInTheDocument(); | ||
const results = await axe(container); | ||
expect(results).toHaveNoViolations(); | ||
}); | ||
}); |
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 |
---|---|---|
|
@@ -17,7 +17,7 @@ Default.args = { | |
content: [ | ||
{ | ||
nodeType: "text", | ||
value: "Quote Text ", | ||
value: "Quote Text", | ||
}, | ||
], | ||
}, | ||
|
23 changes: 23 additions & 0 deletions
23
components/fragment_renderer/fragment_components/QuoteVerticalLineContent.test.js
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,23 @@ | ||
import React from "react"; | ||
import { render, screen } from "@testing-library/react"; | ||
import QuoteVerticalLineContent from "./QuoteVerticalLineContent"; | ||
import { Default } from "./QuoteVerticalLineContent.stories.js"; | ||
import { axe, toHaveNoViolations } from "jest-axe"; | ||
|
||
expect.extend(toHaveNoViolations); | ||
|
||
describe("QuoteVerticalLineContent", () => { | ||
test("renders QuoteVerticalLineContent component with default props", async () => { | ||
const { container } = render( | ||
<QuoteVerticalLineContent {...Default.args} /> | ||
); | ||
expect( | ||
screen.getByText((content) => content.startsWith("Quote Text")) | ||
).toBeInTheDocument(); | ||
expect( | ||
screen.getByText((content) => content.startsWith("Explanation Text")) | ||
).toBeInTheDocument(); | ||
const results = await axe(container); | ||
expect(results).toHaveNoViolations(); | ||
}); | ||
}); |
17 changes: 17 additions & 0 deletions
17
components/fragment_renderer/fragment_components/TextContent.test.js
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,17 @@ | ||
import React from "react"; | ||
import { render, screen } from "@testing-library/react"; | ||
import TextContent from "./TextContent"; | ||
import { Default } from "./TextContent.stories.js"; | ||
import { axe, toHaveNoViolations } from "jest-axe"; | ||
|
||
expect.extend(toHaveNoViolations); | ||
|
||
describe("TextContent", () => { | ||
test("renders TextContent component with default props", async () => { | ||
const { container } = render(<TextContent {...Default.args} />); | ||
expect(screen.getByText((content) => content.startsWith("Every week"))) | ||
.toBeInTheDocument; | ||
const results = await axe(container); | ||
expect(results).toHaveNoViolations(); | ||
}); | ||
}); |
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
29 changes: 29 additions & 0 deletions
29
components/fragment_renderer/fragment_components/TextWithImage.test.js
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,29 @@ | ||
import React from "react"; | ||
import { render, screen } from "@testing-library/react"; | ||
import TextWithImage from "./TextWithImage"; | ||
import { Default } from "./TextWithImage.stories.js"; | ||
import { Vertical } from "./TextWithImage.stories.js"; | ||
import { axe, toHaveNoViolations } from "jest-axe"; | ||
|
||
expect.extend(toHaveNoViolations); | ||
|
||
describe("TextWithImage", () => { | ||
test("renders TextWithImage component with default props", async () => { | ||
const { container } = render(<TextWithImage {...Default.args} />); | ||
expect(screen.getByAltText("image alt text")).toBeInTheDocument(); | ||
expect( | ||
screen.getByText((content) => content.startsWith("Every week")) | ||
).toBeInTheDocument(); | ||
const results = await axe(container); | ||
expect(results).toHaveNoViolations(); | ||
}); | ||
test("renders TextWithImage component with Vertical props", async () => { | ||
const { container } = render(<TextWithImage {...Vertical.args} />); | ||
expect(screen.getByAltText("image alt text")).toBeInTheDocument(); | ||
expect( | ||
screen.getByText((content) => content.startsWith("Every week")) | ||
).toBeInTheDocument(); | ||
const results = await axe(container); | ||
expect(results).toHaveNoViolations(); | ||
}); | ||
}); |