// Copyright (C) 2022 Aravinth Manivannan // SPDX-FileCopyrightText: 2023 Aravinth Manivannan // // SPDX-License-Identifier: AGPL-3.0-or-later import registerShowPassword from "./index"; import {showPassword} from "./index"; const initial_content = `

Signin to mCaptcha

`; it("show password works", () => { document.body.innerHTML = initial_content; const container = ( document.querySelector(".show-password-container") ); const hide = container.querySelector(".show-password--hide"); const show = container.querySelector(".show-password--show"); const password = document.getElementById("password"); show.style.display = "inline"; hide.style.display = "none"; showPassword(); expect(hide.style.display).toEqual("inline"); expect(show.style.display).toEqual("none"); expect(password.type).toEqual("text"); showPassword(); expect(show.style.display).toEqual("inline"); expect(hide.style.display).toEqual("none"); expect(password.type).toEqual("password"); }); it("show password click works", () => { document.body.innerHTML = initial_content; const container = ( document.querySelector(".show-password-container") ); const hide = container.querySelector(".show-password--hide"); const show = container.querySelector(".show-password--show"); const password = document.getElementById("password"); show.style.display = "inline"; hide.style.display = "none"; registerShowPassword(); container.click(); expect(hide.style.display).toEqual("inline"); expect(show.style.display).toEqual("none"); expect(password.type).toEqual("text"); container.click(); expect(show.style.display).toEqual("inline"); expect(hide.style.display).toEqual("none"); expect(password.type).toEqual("password"); });