Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
will0684 committed Sep 24, 2024
1 parent e7bf392 commit 64efdfc
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 7 deletions.
102 changes: 95 additions & 7 deletions __mocks__/mockStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,11 +566,13 @@ export const homePageData = {
data: {
sclabsPageV1ByPath: {
item: {
_path: "/content/dam/decd-endc/content-fragments/sclabs/pages/home",
scId: "PAGES-HOME",
scPageNameEn: "/en/home",
scPageNameFr: "/fr/accueil",
scTitleEn: "Service Canada Labs",
scTitleFr: "Laboratoires de Service Canada",
scPageNameEn: "/en/home",
scPageNameFr: "/fr/accueil",
scBreadcrumbParentPages: [],
scShortTitleEn: null,
scShortTitleFr: null,
scDescriptionEn: {
Expand Down Expand Up @@ -601,14 +603,14 @@ export const homePageData = {
},
],
},
scBreadcrumbParentPages: [],
scSubject: [
"gc:subjects/gv-government-and-politics/government-services",
],
scKeywordsEn: "digital services",
scKeywordsFr: "services numériques",
scContentType: null,
scOwner: null,
scDateIssued: "2023-04-10",
scDateModifiedOverwrite: null,
scAudience: null,
scRegion: null,
Expand Down Expand Up @@ -639,6 +641,9 @@ export const homePageData = {
scId: "COMP-IMAGE-HOME-INTRO",
scLabContent: [
{
_model: {
title: "SCLabs-Content-v1",
},
scId: "CONTENT-HOME-MAIN",
scContentEn: {
json: [
Expand Down Expand Up @@ -800,6 +805,9 @@ export const homePageData = {
},
],
scLabImage: {
_model: {
title: "SCLabs-Image-v1",
},
scId: "SCLABS-HOMEPAGE-IMAGE",
scImageEn: {
_publishUrl:
Expand All @@ -823,12 +831,77 @@ export const homePageData = {
scImageCaptionFr: {
json: null,
},
scLongDescHeadingEn: null,
scLongDescHeadingFr: null,
scLongDescEn: {
json: null,
},
scLongDescFr: {
json: null,
},
},
scLabLayout: "default",
},
{
_model: {
title: "SCLabs-Feature-v1",
},
scId: "FEATURE-SC-LABS-FEEDBACK-SURVEY",
scTitleEn: "Tell us what you think of Service Canada Labs",
scTitleFr:
"Dites-nous ce que vous pensez des laboratoires de Service Canada",
scContentEn: {
json: [
{
nodeType: "paragraph",
content: [
{
nodeType: "text",
value:
"You can help shape this website too. Take a few minutes to tell us about your experience.",
},
],
},
],
},
scContentFr: {
json: [
{
nodeType: "paragraph",
content: [
{
nodeType: "text",
value:
"Vous pouvez aussi contribuer à l'élaboration de ce site Web. Prenez quelques minutes pour nous faire part de votre expérience.",
},
],
},
],
},
scImageEn: null,
scImageFr: null,
scImageAltTextEn: null,
scImageAltTextFr: null,
scFragments: [],
scLabsButton: [
{
scId: "BUTTON-SC-LABS-FEEDBACK-SURVEY",
scTitleEn: "Take the survey",
scTitleFr: "Répondre au sondage",
scDestinationURLEn:
"https://forms-formulaires.alpha.canada.ca/en/id/cm0mjtvrg0014330vn6blw3pi",
scDestinationURLFr:
"https://forms-formulaires.alpha.canada.ca/fr/id/cm0mjtvrg0014330vn6blw3pi",
scButtonType: ["gc:custom/decd-endc/button-type/secondary"],
},
],
},
{
_path:
"/content/dam/decd-endc/content-fragments/sclabs/components/content/home-explore-projects",
_model: {
title: "SCLabs-Content-v1",
},
scId: "CONTENT-HOME-EXPLORE-PROJECTS",
scContentEn: {
json: [
Expand Down Expand Up @@ -860,6 +933,11 @@ export const homePageData = {
},
},
{
_path:
"/content/dam/decd-endc/content-fragments/sclabs/components/alerts/site-features-works-in-progress",
_model: {
title: "SCLabs-Alert-v1",
},
scId: "SITE-FEATURES-WORKS-IN-PROGRESS",
scTitleEn: "This site features works in progress",
scTitleFr: "Ce site présente des travaux en cours",
Expand Down Expand Up @@ -913,10 +991,14 @@ export const homePageData = {
},
],
},
scAlertType: ["gc:custom/decd-endc/alert-type/information"],
},
{
_path:
"/content/dam/decd-endc/content-fragments/sclabs/components/content/home-see-all-projects",
_model: {
title: "SCLabs-Content-v1",
},
scId: "CONTENT-HOME-SEE-ALL-PROJECTS",
scContentEn: {
json: [
Expand All @@ -926,7 +1008,7 @@ export const homePageData = {
{
nodeType: "link",
data: {
href: "/en/projects.html",
href: "/en/projects",
},
value: "See all projects",
},
Expand All @@ -942,7 +1024,7 @@ export const homePageData = {
{
nodeType: "link",
data: {
href: "/fr/projets.html",
href: "/fr/projets",
},
value: "Consulter tous les projets",
},
Expand All @@ -954,6 +1036,9 @@ export const homePageData = {
{
_path:
"/content/dam/decd-endc/content-fragments/sclabs/components/content/home-read-updates",
_model: {
title: "SCLabs-Content-v1",
},
scId: "CONTENT-HOME-READ-UPDATES",
scContentEn: {
json: [
Expand Down Expand Up @@ -988,6 +1073,9 @@ export const homePageData = {
{
_path:
"/content/dam/decd-endc/content-fragments/sclabs/components/content/home-see-all-updates",
_model: {
title: "SCLabs-Content-v1",
},
scId: "CONTENT-HOME-SEE-ALL-UPDATES",
scContentEn: {
json: [
Expand All @@ -997,7 +1085,7 @@ export const homePageData = {
{
nodeType: "link",
data: {
href: "/en/updates.html",
href: "/en/updates",
},
value: "See all updates",
},
Expand All @@ -1013,7 +1101,7 @@ export const homePageData = {
{
nodeType: "link",
data: {
href: "/fr/mises-a-jour.html",
href: "/fr/mises-a-jour",
},
value: "Consulter toutes les mises à jour",
},
Expand Down
19 changes: 19 additions & 0 deletions components/molecules/SurveyCTA.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from "react";
import { Primary } from "./SurveyCTA.stories";
import "@testing-library/jest-dom/extend-expect";
import { axe, toHaveNoViolations } from "jest-axe";
import { render, screen } from "@testing-library/react";

expect.extend(toHaveNoViolations);

describe("SurveyCTA", () => {
it("renders without errors", () => {
render(<Primary {...Primary.args} />);
screen.getByText("CTA Heading");
});
it("has no a11y violations", async () => {
const { container } = render(<Primary {...Primary.args} />);
const results = await axe(container);
expect(results).toHaveNoViolations();
});
});

0 comments on commit 64efdfc

Please sign in to comment.