lint, unit tests

This commit is contained in:
peintnermax
2023-08-02 15:21:34 +02:00
parent b5a5212dc8
commit 284859c21a
3 changed files with 28 additions and 16 deletions

View File

@@ -14,8 +14,8 @@ describe("register idps", () => {
it("should redirect the user to the correct url", () => {
cy.visit("/register/idp");
cy.get('button[e2e="google"]').click();
cy.origin(IDP_URL, ()=> {
cy.origin(IDP_URL, () => {
cy.location("href", { timeout: 10_000 }).should("eq", IDP_URL);
})
});
});
});

View File

@@ -7,9 +7,15 @@ describe("<SignInWithGitlab />", () => {
expect(container.firstChild).toBeDefined();
});
it("displays the correct text", () => {
it("displays the default text", () => {
render(<SignInWithGitlab />);
const signInText = screen.getByText(/Sign in with Gitlab/i);
expect(signInText).toBeInTheDocument();
});
it("displays the given text", () => {
render(<SignInWithGitlab name={"Gitlab"} />);
const signInText = screen.getByText(/Gitlab/i);
expect(signInText).toBeInTheDocument();
});
});

View File

@@ -1,15 +1,21 @@
import { render, screen } from '@testing-library/react';
import { SignInWithGitlab } from './SignInWithGitlab';
import { render, screen } from "@testing-library/react";
import { SignInWithGoogle } from "./SignInWithGoogle";
describe('<SignInWithGitlab />', () => {
it('renders without crashing', () => {
const { container } = render(<SignInWithGitlab />);
expect(container.firstChild).toBeDefined();
});
describe("<SignInWithGoogle />", () => {
it("renders without crashing", () => {
const { container } = render(<SignInWithGoogle />);
expect(container.firstChild).toBeDefined();
});
it('displays the correct text', () => {
render(<SignInWithGitlab />);
const signInText = screen.getByText(/Sign in with Gitlab/i);
expect(signInText).toBeInTheDocument();
});
it("displays the default text", () => {
render(<SignInWithGoogle />);
const signInText = screen.getByText(/Sign in with Google/i);
expect(signInText).toBeInTheDocument();
});
it("displays the given text", () => {
render(<SignInWithGoogle name={"Google"} />);
const signInText = screen.getByText(/Google/i);
expect(signInText).toBeInTheDocument();
});
});