/* * Copyright (C) 2021 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 {getAddForm, trim} from "../../setupTests"; import updateInputs from "./updateInputs"; import CONST from "../../const"; import log from "../../../../../../logger"; import {MODE} from "../../../../../../logger"; import {setupAddlevels} from "./setupTests"; document.body.innerHTML = getAddForm(); log.setMode(MODE.none); it("updateInputs works", () => { setupAddlevels(); // removing level 2 const level = 2; const levelGroup = document.querySelector( `#${CONST.LEVEL_FIELDSET_ID_WITHOUT_LEVEL}${level}`, ); const newLevel = 20; updateInputs(levelGroup, newLevel); const inputs = >( levelGroup.querySelectorAll(`.${CONST.LEVEL_INPUT_CLASS}`) ); inputs.forEach(input => { if (input.id.includes(CONST.VISITOR_WITHOUT_LEVEL)) { expect(input.id).toBe(`${CONST.VISITOR_WITHOUT_LEVEL}${newLevel}`); console.log("checking visitor"); } else { // if (input.id.includes(CONST.DIFFICULTY_WITHOUT_LEVEL)) { console.log("checking difficulty"); expect(input.id).toBe(`${CONST.DIFFICULTY_WITHOUT_LEVEL}${newLevel}`); } }); expect(trim(document.body.innerHTML)).toBe(trim(update())); }); /** get initial form to test remove button functionality */ export const update = (): string => { return `

Add Sitekey

Level 1
Level 2
Level 3
Level 4
`; };