Skip to content

Commit

Permalink
test(frontend): ✅ Fix blog test
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakob Grøtan Gregusson committed Apr 29, 2024
1 parent c604a28 commit 5eacc84
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
6 changes: 4 additions & 2 deletions frontend/src/components/fullBlogCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export default function FullBlogCard({
return (
<Link
href={"/blog/" + article.slug}
data-testid="blogCardLink"
className="flex flex-col border bg-background p-5 text-card-foreground hover:border-primary"
data-testid="blogCardLink"
>
<BlogCard className={cn(className, "")}>
<BlogCardHeader>
Expand Down Expand Up @@ -77,7 +77,9 @@ export default function FullBlogCard({
{formatDate(article.datePublished)}
</p>
</div>
<BlogCardTitle>{article.title}</BlogCardTitle>
<BlogCardTitle data-testid="blogCardTitle">
{article.title}
</BlogCardTitle>
</BlogCardHeader>
<BlogCardContent>
<p className="break-words">
Expand Down
13 changes: 1 addition & 12 deletions frontend/tests/componentTests/fullblogcard.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ test("FullBlogCard renders correctly", async ({ mount }) => {
await expect(component).toBeVisible();

//Check if title is correct
await expect(component.getByTestId("blogCardLink")).toContainText(
await expect(component.getByTestId("blogCardTitle")).toContainText(
"Mock Article Title",
);

Expand All @@ -50,15 +50,4 @@ test("FullBlogCard renders correctly", async ({ mount }) => {

//Check if the tag is correct
await expect(component.getByTestId("articleTag")).toHaveText("Projects");

//Check if the urls on the links are correct
await expect(component.getByTestId("blogCardLink")).toHaveAttribute(
"href",
"/blog/mock-article-slug",
);

await expect(component.getByText("Read more")).toHaveAttribute(
"href",
"/blog/mock-article-slug",
);
});

0 comments on commit 5eacc84

Please sign in to comment.