/* * Copyright (C) 2022 Aravinth Manivannan * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ 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"); });