From 4bfae414facfc5b28807b2027fc6272c0dce0fe2 Mon Sep 17 00:00:00 2001 From: Felix Schlegel Date: Sun, 8 Dec 2024 13:46:59 +0100 Subject: [PATCH] test: add test case for forgot password link --- .../integration/input/password-input.test.ts | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tests/integration/input/password-input.test.ts b/tests/integration/input/password-input.test.ts index cf413e2..355cc4d 100644 --- a/tests/integration/input/password-input.test.ts +++ b/tests/integration/input/password-input.test.ts @@ -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, }, }); @@ -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(); @@ -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); + }); });