Skip to content

Commit

Permalink
test: add test case for forgot password link
Browse files Browse the repository at this point in the history
  • Loading branch information
Slartibartfass2 committed Dec 17, 2024
1 parent 700c4c8 commit 4bfae41
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion tests/integration/input/password-input.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import { assert, describe, expect, test } from "vitest";
describe("PasswordInput", () => {
const validPassword = "z's?c].e2x<@($\"<#;\\A]]3D@F)/^v^!";

test("When props are provided, then label and input are shown", () => {
test("When props are provided, then label, link and input are shown", () => {
render(PasswordInput, {
target: document.body,
props: {
value: validPassword,
showForgotPasswordLink: true,
},
});

Expand All @@ -18,6 +19,11 @@ describe("PasswordInput", () => {
expect(label).toBeInTheDocument();
expect(label).toHaveTextContent("Password");

// Link exists
const link = document.getElementsByTagName("a")[0];
expect(link).toBeInTheDocument();
expect(link).toHaveTextContent("Forgot your password?");

// Input exists
const inputElement = document.getElementById("password-input");
expect(inputElement).toBeInTheDocument();
Expand Down Expand Up @@ -94,4 +100,16 @@ describe("PasswordInput", () => {
expect(input).toHaveAttribute("type", "password");
});
});

test("When `showForgotPasswordLink` is false, then link is not shown", () => {
render(PasswordInput, {
target: document.body,
props: {
showForgotPasswordLink: false,
},
});

const link = document.getElementsByTagName("a");
expect(link).toHaveLength(0);
});
});

0 comments on commit 4bfae41

Please sign in to comment.