diff options
Diffstat (limited to 'test/settings/components')
-rw-r--r-- | test/settings/components/form/BlacklistForm.test.tsx | 20 | ||||
-rw-r--r-- | test/settings/components/form/KeymapsForm.test.tsx | 11 | ||||
-rw-r--r-- | test/settings/components/form/PropertiesForm.test.tsx | 19 | ||||
-rw-r--r-- | test/settings/components/form/SearchEngineForm.test.tsx | 33 | ||||
-rw-r--r-- | test/settings/components/ui/Radio.test.tsx | 11 | ||||
-rw-r--r-- | test/settings/components/ui/Text.test.tsx | 11 | ||||
-rw-r--r-- | test/settings/components/ui/TextArea.test.tsx | 15 |
7 files changed, 53 insertions, 67 deletions
diff --git a/test/settings/components/form/BlacklistForm.test.tsx b/test/settings/components/form/BlacklistForm.test.tsx index 9840856..bd1a1e8 100644 --- a/test/settings/components/form/BlacklistForm.test.tsx +++ b/test/settings/components/form/BlacklistForm.test.tsx @@ -6,7 +6,6 @@ import React from "react"; import ReactDOM from "react-dom"; import ReactTestRenderer from "react-test-renderer"; import ReactTestUtils from "react-dom/test-utils"; -import { expect } from "chai"; import BlacklistForm from "../../../../src/settings/components/form/BlacklistForm"; import Blacklist from "../../../../src/shared/settings/Blacklist"; @@ -24,15 +23,15 @@ describe("settings/form/BlacklistForm", () => { const rows = root .findAllByType("div") .filter((instance) => instance.props.role === "listitem"); - expect(rows).to.have.lengthOf(2); - expect(rows[0].findByProps({ name: "url" }).props.value).to.equal( + expect(rows).toHaveLength(2); + expect(rows[0].findByProps({ name: "url" }).props.value).toEqual( "*.slack.com" ); - expect(rows[1].findByProps({ name: "url" }).props.value).to.equal( + expect(rows[1].findByProps({ name: "url" }).props.value).toEqual( "www.google.com/maps" ); - expect(() => root.findByType(AddButton)).not.throw(); + expect(() => root.findByType(AddButton)).not.toThrow(); }); it("renders blank value", () => { @@ -41,7 +40,7 @@ describe("settings/form/BlacklistForm", () => { const rows = root.findAllByProps({ className: "form-blacklist-form-row", }); - expect(rows).to.be.empty; + expect(rows).toHaveLength(0); }); }); @@ -64,10 +63,7 @@ describe("settings/form/BlacklistForm", () => { value={Blacklist.fromJSON(["*.slack.com", "www.google.com/maps*"])} onChange={(value) => { const urls = value.items.map((item) => item.pattern); - expect(urls).to.have.members([ - "gitter.im", - "www.google.com/maps*", - ]); + expect(urls).toEqual(["gitter.im", "www.google.com/maps*"]); done(); }} />, @@ -89,7 +85,7 @@ describe("settings/form/BlacklistForm", () => { value={Blacklist.fromJSON(["*.slack.com", "www.google.com/maps*"])} onChange={(value) => { const urls = value.items.map((item) => item.pattern); - expect(urls).to.have.members(["www.google.com/maps*"]); + expect(urls).toEqual(["www.google.com/maps*"]); done(); }} />, @@ -108,7 +104,7 @@ describe("settings/form/BlacklistForm", () => { value={Blacklist.fromJSON(["*.slack.com"])} onChange={(value) => { const urls = value.items.map((item) => item.pattern); - expect(urls).to.have.members(["*.slack.com", ""]); + expect(urls).toEqual(["*.slack.com", ""]); done(); }} />, diff --git a/test/settings/components/form/KeymapsForm.test.tsx b/test/settings/components/form/KeymapsForm.test.tsx index 8bdbeb4..4701a96 100644 --- a/test/settings/components/form/KeymapsForm.test.tsx +++ b/test/settings/components/form/KeymapsForm.test.tsx @@ -8,7 +8,6 @@ import ReactTestRenderer from "react-test-renderer"; import ReactTestUtils from "react-dom/test-utils"; import KeymapsForm from "../../../../src/settings/components/form/KeymapsForm"; import { FormKeymaps } from "../../../../src/shared/SettingData"; -import { expect } from "chai"; describe("settings/form/KeymapsForm", () => { describe("render", () => { @@ -25,8 +24,8 @@ describe("settings/form/KeymapsForm", () => { const inputj = root.findByProps({ id: 'scroll.vertically?{"count":1}' }); const inputk = root.findByProps({ id: 'scroll.vertically?{"count":-1}' }); - expect(inputj.props.value).to.equal("j"); - expect(inputk.props.value).to.equal("k"); + expect(inputj.props.value).toEqual("j"); + expect(inputk.props.value).toEqual("k"); }); it("renders blank value", () => { @@ -35,8 +34,8 @@ describe("settings/form/KeymapsForm", () => { const inputj = root.findByProps({ id: 'scroll.vertically?{"count":1}' }); const inputk = root.findByProps({ id: 'scroll.vertically?{"count":-1}' }); - expect(inputj.props.value).to.be.empty; - expect(inputk.props.value).to.be.empty; + expect(inputj.props.value).toHaveLength(0); + expect(inputk.props.value).toHaveLength(0); }); }); @@ -61,7 +60,7 @@ describe("settings/form/KeymapsForm", () => { 'scroll.vertically?{"count":-1}': "k", })} onChange={(value) => { - expect(value.toJSON()['scroll.vertically?{"count":1}']).to.equal( + expect(value.toJSON()['scroll.vertically?{"count":1}']).toEqual( "jjj" ); done(); diff --git a/test/settings/components/form/PropertiesForm.test.tsx b/test/settings/components/form/PropertiesForm.test.tsx index df8f95e..0b481ab 100644 --- a/test/settings/components/form/PropertiesForm.test.tsx +++ b/test/settings/components/form/PropertiesForm.test.tsx @@ -7,7 +7,6 @@ import ReactDOM from "react-dom"; import ReactTestRenderer from "react-test-renderer"; import ReactTestUtils from "react-dom/test-utils"; import PropertiesForm from "../../../../src/settings/components/form/PropertiesForm"; -import { expect } from "chai"; describe("settings/form/PropertiesForm", () => { describe("render", () => { @@ -29,16 +28,16 @@ describe("settings/form/PropertiesForm", () => { ).root; let input = root.findByProps({ name: "mystr" }); - expect(input.props.type).to.equals("text"); - expect(input.props.value).to.equal("abc"); + expect(input.props.type).toEqual("text"); + expect(input.props.value).toEqual("abc"); input = root.findByProps({ name: "mynum" }); - expect(input.props.type).to.equals("number"); - expect(input.props.value).to.equal(123); + expect(input.props.type).toEqual("number"); + expect(input.props.value).toEqual(123); input = root.findByProps({ name: "mybool" }); - expect(input.props.type).to.equals("checkbox"); - expect(input.props.value).to.equal(true); + expect(input.props.type).toEqual("checkbox"); + expect(input.props.value).toEqual(true); }); }); @@ -61,7 +60,7 @@ describe("settings/form/PropertiesForm", () => { types={{ myvalue: "string" }} value={{ myvalue: "abc" }} onChange={(value) => { - expect(value).to.have.property("myvalue", "abcd"); + expect(value).toHaveProperty("myvalue", "abcd"); done(); }} />, @@ -83,7 +82,7 @@ describe("settings/form/PropertiesForm", () => { types={{ myvalue: "number" }} value={{ "": 123 }} onChange={(value) => { - expect(value).to.have.property("myvalue", 1234); + expect(value).toHaveProperty("myvalue", 1234); done(); }} />, @@ -105,7 +104,7 @@ describe("settings/form/PropertiesForm", () => { types={{ myvalue: "boolean" }} value={{ myvalue: false }} onChange={(value) => { - expect(value).to.have.property("myvalue", true); + expect(value).toHaveProperty("myvalue", true); done(); }} />, diff --git a/test/settings/components/form/SearchEngineForm.test.tsx b/test/settings/components/form/SearchEngineForm.test.tsx index c9a68b4..8b84e12 100644 --- a/test/settings/components/form/SearchEngineForm.test.tsx +++ b/test/settings/components/form/SearchEngineForm.test.tsx @@ -8,7 +8,6 @@ import ReactTestRenderer from "react-test-renderer"; import ReactTestUtils from "react-dom/test-utils"; import SearchForm from "../../../../src/settings/components/form/SearchForm"; import { FormSearch } from "../../../../src/shared/SettingData"; -import { expect } from "chai"; describe("settings/form/SearchForm", () => { describe("render", () => { @@ -28,16 +27,16 @@ describe("settings/form/SearchForm", () => { const names = root .findAllByType("input") .filter((instance) => instance.props.name === "name"); - expect(names).to.have.lengthOf(2); - expect(names[0].props.value).to.equal("google"); - expect(names[1].props.value).to.equal("yahoo"); + expect(names).toHaveLength(2); + expect(names[0].props.value).toEqual("google"); + expect(names[1].props.value).toEqual("yahoo"); const urls = root .findAllByType("input") .filter((instance) => instance.props.name === "url"); - expect(urls).to.have.lengthOf(2); - expect(urls[0].props.value).to.equal("google.com"); - expect(urls[1].props.value).to.equal("yahoo.com"); + expect(urls).toHaveLength(2); + expect(urls[0].props.value).toEqual("google.com"); + expect(urls[1].props.value).toEqual("yahoo.com"); }); }); @@ -66,9 +65,9 @@ describe("settings/form/SearchForm", () => { })} onChange={(value) => { const json = value.toJSON(); - expect(json.default).to.equal("louvre"); - expect(json.engines).to.have.lengthOf(2); - expect(json.engines).to.have.deep.members([ + expect(json.default).toEqual("louvre"); + expect(json.engines).toHaveLength(2); + expect(json.engines).toEqual([ ["louvre", "google.com"], ["yahoo", "yahoo.com"], ]); @@ -105,11 +104,9 @@ describe("settings/form/SearchForm", () => { })} onChange={(value) => { const json = value.toJSON(); - expect(json.default).to.equal("yahoo"); - expect(json.engines).to.have.lengthOf(1); - expect(json.engines).to.have.deep.members([ - ["yahoo", "yahoo.com"], - ]); + expect(json.default).toEqual("yahoo"); + expect(json.engines).toHaveLength(1); + expect(json.engines).toEqual([["yahoo", "yahoo.com"]]); done(); }} />, @@ -133,9 +130,9 @@ describe("settings/form/SearchForm", () => { })} onChange={(value) => { const json = value.toJSON(); - expect(json.default).to.equal("yahoo"); - expect(json.engines).to.have.lengthOf(2); - expect(json.engines).to.have.deep.members([ + expect(json.default).toEqual("yahoo"); + expect(json.engines).toHaveLength(2); + expect(json.engines).toEqual([ ["google", "google.com"], ["", ""], ]); diff --git a/test/settings/components/ui/Radio.test.tsx b/test/settings/components/ui/Radio.test.tsx index bce4d3a..e2bf214 100644 --- a/test/settings/components/ui/Radio.test.tsx +++ b/test/settings/components/ui/Radio.test.tsx @@ -6,7 +6,6 @@ import React from "react"; import ReactDOM from "react-dom"; import ReactTestUtils from "react-dom/test-utils"; import Radio from "../../../../src/settings/components/ui/Radio"; -import { expect } from "chai"; describe("settings/ui/Radio", () => { let container: HTMLDivElement; @@ -30,10 +29,10 @@ describe("settings/ui/Radio", () => { const label = document.querySelector("label")!; const input = document.querySelector("input")!; - expect(label.textContent).to.contain("myfield"); - expect(input.type).to.contain("radio"); - expect(input.name).to.contain("myradio"); - expect(input.value).to.contain("myvalue"); + expect(label.textContent).toEqual("myfield"); + expect(input.type).toEqual("radio"); + expect(input.name).toEqual("myradio"); + expect(input.value).toEqual("myvalue"); }); it("invoke onChange", (done) => { @@ -45,7 +44,7 @@ describe("settings/ui/Radio", () => { label="myfield" value="myvalue" onChange={(e) => { - expect((e.target as HTMLInputElement).checked).to.be.true; + expect((e.target as HTMLInputElement).checked).toBeTruthy; done(); }} />, diff --git a/test/settings/components/ui/Text.test.tsx b/test/settings/components/ui/Text.test.tsx index 86c4132..a8e0bf9 100644 --- a/test/settings/components/ui/Text.test.tsx +++ b/test/settings/components/ui/Text.test.tsx @@ -6,7 +6,6 @@ import React from "react"; import ReactDOM from "react-dom"; import ReactTestUtils from "react-dom/test-utils"; import Text from "../../../../src/settings/components/ui/Text"; -import { expect } from "chai"; describe("settings/ui/Text", () => { let container: HTMLDivElement; @@ -30,10 +29,10 @@ describe("settings/ui/Text", () => { const label = document.querySelector("label")!; const input = document.querySelector("input")!; - expect(label.textContent).to.contain("myfield"); - expect(input.type).to.contain("text"); - expect(input.name).to.contain("myname"); - expect(input.value).to.contain("myvalue"); + expect(label.textContent?.includes("myfield")).toBeTruthy; + expect(input.type).toEqual("text"); + expect(input.name).toEqual("myname"); + expect(input.value).toEqual("myvalue"); }); it("invoke onChange", (done) => { @@ -44,7 +43,7 @@ describe("settings/ui/Text", () => { label="myfield" value="myvalue" onChange={(e) => { - expect((e.target as HTMLInputElement).value).to.equal("newvalue"); + expect((e.target as HTMLInputElement).value).toEqual("newvalue"); done(); }} />, diff --git a/test/settings/components/ui/TextArea.test.tsx b/test/settings/components/ui/TextArea.test.tsx index 84c0c93..76caec2 100644 --- a/test/settings/components/ui/TextArea.test.tsx +++ b/test/settings/components/ui/TextArea.test.tsx @@ -6,7 +6,6 @@ import React from "react"; import ReactDOM from "react-dom"; import ReactTestUtils from "react-dom/test-utils"; import TextArea from "../../../../src/settings/components/ui/TextArea"; -import { expect } from "chai"; describe("settings/ui/TextArea", () => { let container: HTMLDivElement; @@ -36,11 +35,11 @@ describe("settings/ui/TextArea", () => { const label = document.querySelector("label")!; const textarea = document.querySelector("textarea")!; const error = document.querySelector("[role=alert]")!; - expect(label.textContent).to.contain("myfield"); - expect(textarea.nodeName).to.contain("TEXTAREA"); - expect(textarea.name).to.contain("myname"); - expect(textarea.value).to.contain("myvalue"); - expect(error.textContent).to.contain("myerror"); + expect(label.textContent).toEqual("myfield"); + expect(textarea.nodeName).toEqual("TEXTAREA"); + expect(textarea.name).toEqual("myname"); + expect(textarea.value).toEqual("myvalue"); + expect(error.textContent).toEqual("myerror"); }); it("invoke onChange", (done) => { @@ -51,9 +50,7 @@ describe("settings/ui/TextArea", () => { label="myfield" value="myvalue" onChange={(e) => { - expect((e.target as HTMLTextAreaElement).value).to.equal( - "newvalue" - ); + expect((e.target as HTMLTextAreaElement).value).toEqual("newvalue"); done(); }} />, |