diff options
Diffstat (limited to 'test/content/presenters/Hint.test.ts')
-rw-r--r-- | test/content/presenters/Hint.test.ts | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/test/content/presenters/Hint.test.ts b/test/content/presenters/Hint.test.ts index 1a7c868..b3b2d19 100644 --- a/test/content/presenters/Hint.test.ts +++ b/test/content/presenters/Hint.test.ts @@ -1,8 +1,11 @@ +/** + * @jest-environment jsdom + */ + import AbstractHint, { LinkHint, InputHint, } from "../../../src/content/presenters/Hint"; -import { expect } from "chai"; class Hint extends AbstractHint {} @@ -17,7 +20,7 @@ describe("Hint", () => { new Hint(link, "abc"); const elem = document.querySelector(".vimvixen-hint"); - expect(elem!.textContent!.trim()).to.be.equal("abc"); + expect(elem!.textContent!.trim()).toEqual("abc"); }); }); @@ -29,7 +32,7 @@ describe("Hint", () => { hint.show(); const elem = document.querySelector(".vimvixen-hint") as HTMLElement; - expect(elem.style.display).to.not.equal("none"); + expect(elem.style.display).not.toEqual("none"); }); }); @@ -40,7 +43,7 @@ describe("Hint", () => { hint.hide(); const elem = document.querySelector(".vimvixen-hint") as HTMLElement; - expect(elem.style.display).to.equal("none"); + expect(elem.style.display).toEqual("none"); }); }); @@ -50,9 +53,9 @@ describe("Hint", () => { const hint = new Hint(link, "abc"); const elem = document.querySelector(".vimvixen-hint")!; - expect(elem.parentElement).to.not.be.null; + expect(elem.parentElement).not.toBeNull; hint.remove(); - expect(elem.parentElement).to.be.null; + expect(elem.parentElement).toBeNull; }); }); }); @@ -71,7 +74,7 @@ describe("LinkHint", () => { const link = document.getElementById("test-link1") as HTMLAnchorElement; const hint = new LinkHint(link, "abc"); - expect(hint.getLink()).to.equal("https://google.com/"); + expect(hint.getLink()).toEqual("https://google.com/"); }); }); @@ -80,12 +83,12 @@ describe("LinkHint", () => { let link = document.getElementById("test-link1") as HTMLAnchorElement; let hint = new LinkHint(link, "abc"); - expect(hint.getLinkTarget()).to.be.null; + expect(hint.getLinkTarget()).toBeNull; link = document.getElementById("test-link2") as HTMLAnchorElement; hint = new LinkHint(link, "abc"); - expect(hint.getLinkTarget()).to.equal("_blank"); + expect(hint.getLinkTarget()).toEqual("_blank"); }); }); @@ -104,7 +107,7 @@ describe("LinkHint", () => { describe("InputHint", () => { describe("#activate()", () => { - context("<input>", () => { + describe("<input>", () => { beforeEach(() => { document.body.innerHTML = `<input id='test-input'></input>`; }); @@ -114,11 +117,11 @@ describe("InputHint", () => { const hint = new InputHint(input, "abc"); hint.activate(); - expect(document.activeElement).to.equal(input); + expect(document.activeElement).toEqual(input); }); }); - context('<input type="checkbox">', () => { + describe('<input type="checkbox">', () => { beforeEach(() => { document.body.innerHTML = `<input type="checkbox" id='test-input'></input>`; }); @@ -128,10 +131,10 @@ describe("InputHint", () => { const hint = new InputHint(input, "abc"); hint.activate(); - expect(input.checked).to.be.true; + expect(input.checked).toBeTruthy; }); }); - context("<textarea>", () => { + describe("<textarea>", () => { beforeEach(() => { document.body.innerHTML = `<textarea id='test-textarea'></textarea>`; }); @@ -143,11 +146,11 @@ describe("InputHint", () => { const hint = new InputHint(textarea, "abc"); hint.activate(); - expect(document.activeElement).to.equal(textarea); + expect(document.activeElement).toEqual(textarea); }); }); - context("<button>", () => { + describe("<button>", () => { beforeEach(() => { document.body.innerHTML = `<button id='test-button'></button>`; }); |