Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
carolineBda committed Jan 9, 2025
1 parent bfdc6a4 commit 4e2a2a1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { useEffect, useRef, useState } from "react";
import { Button } from "@codegouvfr/react-dsfr/Button";
import { css } from "@styled-system/css";
import { fr } from "@codegouvfr/react-dsfr";
import { RelatedItem, sources } from "../documents";
import { sources } from "../documents";
import { RelatedItems } from "../common/RelatedItems";
import { Share } from "../common/Share";
import { Feedback } from "../layout/feedback";
Expand Down Expand Up @@ -120,7 +120,8 @@ export function ContributionLayout({ contribution }: Props) {
}))}
/>
<h1 className={fr.cx("fr-mb-6w")}>
{title}{" "}
{title}
{!isGeneric && " "}
{!isGeneric && (
<span className={`${fr.cx("fr-h2")} ${h1}`}>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,35 @@ const contribution = {
source: "contributions",
linkedContent: [],
references: [],
idcc: "",
idcc: "0000",
metas: {
title: "SEO Title",
description: "SEO Description",
},
title: "La période d’essai peut-elle être renouvelée ?",
breadcrumbs: [],
slug: "slug",
ccnShortTitle: "Nom de la CC",
} as Partial<ElasticSearchContribution> as any;

describe("<PageContribution />", () => {
it("should render title with cc name in it", () => {
it("should render title only if generic", () => {
const { getByRole } = render(
<ContributionLayout contribution={contribution} relatedItems={[]} />
<ContributionLayout contribution={contribution} />
);
const titreH1 = getByRole("heading", { level: 1 });
expect(titreH1.textContent).toBe(
"La période d’essai peut-elle être renouvelée ?"
);
});
it("should render title with only question", () => {
contribution.ccnShortTitle = "Ce short title fait plus de 15 caractères";
it("should render title with cc short name if contribution with CC", () => {
contribution.idcc = "0029";
const { getByRole } = render(
<ContributionLayout contribution={contribution} relatedItems={[]} />
<ContributionLayout contribution={contribution} />
);
const titreH1 = getByRole("heading", { level: 1 });
expect(titreH1.textContent).toBe(
"La période d’essai peut-elle être renouvelée ?"
"La période d’essai peut-elle être renouvelée ? Nom de la CC"
);
});
});

0 comments on commit 4e2a2a1

Please sign in to comment.