/* * 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 getNumLevels from "./levels/getNumLevels"; import {getAddForm, trim, addLevel} from "./setupTests"; import setup from "../../../../../components/error/setUpTests"; document.body.innerHTML = getAddForm(); document.body.appendChild(setup()); jest.useFakeTimers(); it("addLevelButton works", () => { expect(getNumLevels()).toBe(1); // add a level addLevel(2, 4); expect(getNumLevels()).toBe(2); // add second level addLevel(4, 9); expect(getNumLevels()).toBe(3); const a = document.body.innerHTML; expect(trim(a)).toBe(trim(finalHtml())); // try to add duplicate level addLevel(2, 4); expect(getNumLevels()).toBe(3); // try to add negative parameters addLevel(-4, -9); expect(getNumLevels()).toBe(3); }); const finalHtml = () => { return `

Add Sitekey

Level 1
Level 2
Level 3
`; };