fix unit tests

This commit is contained in:
peintnermax
2024-10-11 08:40:57 +02:00
parent 2fb9403874
commit 4cd24fbddc
2 changed files with 17 additions and 10 deletions

View File

@@ -1,18 +1,22 @@
import { afterEach, describe, expect, test } from "vitest"; import { afterEach, describe, expect, test } from "vitest";
import { cleanup, render, screen } from "@testing-library/react"; import { cleanup, render, screen } from "@testing-library/react";
import { NextIntlClientProvider, useMessages } from "next-intl"; import { NextIntlClientProvider } from "next-intl";
import { SignInWithGitlab } from "./sign-in-with-gitlab"; import { SignInWithGitlab } from "./sign-in-with-gitlab";
afterEach(cleanup); afterEach(cleanup);
describe("<SignInWithGitlab />", async () => { describe("<SignInWithGitlab />", async () => {
const messages = useMessages(); const messages = {
idp: {
signInWithGitlab: "Sign in with GitLab",
},
};
test("renders without crashing", () => { test("renders without crashing", () => {
const { container } = render( const { container } = render(
<NextIntlClientProvider messages={messages}> <NextIntlClientProvider locale="en" messages={messages}>
<SignInWithGitlab /> <SignInWithGitlab />
</NextIntlClientProvider>, </NextIntlClientProvider>,
); );
@@ -21,7 +25,7 @@ describe("<SignInWithGitlab />", async () => {
test("displays the default text", () => { test("displays the default text", () => {
render( render(
<NextIntlClientProvider messages={messages}> <NextIntlClientProvider locale="en" messages={messages}>
<SignInWithGitlab /> <SignInWithGitlab />
</NextIntlClientProvider>, </NextIntlClientProvider>,
); );
@@ -31,7 +35,7 @@ describe("<SignInWithGitlab />", async () => {
test("displays the given text", () => { test("displays the given text", () => {
render( render(
<NextIntlClientProvider messages={messages}> <NextIntlClientProvider locale="en" messages={messages}>
<SignInWithGitlab name={"Gitlab"} /> <SignInWithGitlab name={"Gitlab"} />
</NextIntlClientProvider>, </NextIntlClientProvider>,
); );

View File

@@ -2,17 +2,20 @@ import { afterEach, describe, expect, test } from "vitest";
import { cleanup, render, screen } from "@testing-library/react"; import { cleanup, render, screen } from "@testing-library/react";
import { NextIntlClientProvider } from "next-intl"; import { NextIntlClientProvider } from "next-intl";
import { getMessages } from "next-intl/server";
import { SignInWithGoogle } from "./sign-in-with-google"; import { SignInWithGoogle } from "./sign-in-with-google";
afterEach(cleanup); afterEach(cleanup);
describe("<SignInWithGoogle />", async () => { describe("<SignInWithGoogle />", async () => {
const messages = await getMessages({ locale: "en" }); const messages = {
idp: {
signInWithGoogle: "Sign in with Google",
},
};
test("renders without crashing", () => { test("renders without crashing", () => {
const { container } = render( const { container } = render(
<NextIntlClientProvider messages={messages}> <NextIntlClientProvider locale="en" messages={messages}>
<SignInWithGoogle /> <SignInWithGoogle />
</NextIntlClientProvider>, </NextIntlClientProvider>,
); );
@@ -21,7 +24,7 @@ describe("<SignInWithGoogle />", async () => {
test("displays the default text", () => { test("displays the default text", () => {
render( render(
<NextIntlClientProvider messages={messages}> <NextIntlClientProvider locale="en" messages={messages}>
<SignInWithGoogle /> <SignInWithGoogle />
</NextIntlClientProvider>, </NextIntlClientProvider>,
); );
@@ -31,7 +34,7 @@ describe("<SignInWithGoogle />", async () => {
test("displays the given text", () => { test("displays the given text", () => {
render( render(
<NextIntlClientProvider messages={messages}> <NextIntlClientProvider locale="en" messages={messages}>
<SignInWithGoogle name={"Google"} /> <SignInWithGoogle name={"Google"} />
</NextIntlClientProvider>, </NextIntlClientProvider>,
); );