diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2021-10-10 01:42:37 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-10 01:42:37 +0000 |
commit | dfcefe1b84cc96ead1c8d8f9aa65ff05ccd70378 (patch) | |
tree | 12f1a4ed6da8fd96c034d23bcf08b1535bca1113 /test/settings/components/form | |
parent | 24f4f06db6572d81cadfe191f36c433a79985871 (diff) | |
parent | 039095e18562c44edda2c5a83a3d82c2e220b370 (diff) |
Merge pull request #1267 from ueokande/move-to-jest
Move to Jest
Diffstat (limited to 'test/settings/components/form')
4 files changed, 53 insertions, 46 deletions
diff --git a/test/settings/components/form/BlacklistForm.test.tsx b/test/settings/components/form/BlacklistForm.test.tsx index 8727c59..bd1a1e8 100644 --- a/test/settings/components/form/BlacklistForm.test.tsx +++ b/test/settings/components/form/BlacklistForm.test.tsx @@ -1,8 +1,11 @@ +/** + * @jest-environment jsdom + */ + 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"; @@ -20,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", () => { @@ -37,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); }); }); @@ -60,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(); }} />, @@ -85,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(); }} />, @@ -104,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 1cec889..4701a96 100644 --- a/test/settings/components/form/KeymapsForm.test.tsx +++ b/test/settings/components/form/KeymapsForm.test.tsx @@ -1,10 +1,13 @@ +/** + * @jest-environment jsdom + */ + import React from "react"; import ReactDOM from "react-dom"; 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", () => { @@ -21,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", () => { @@ -31,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); }); }); @@ -57,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 acf02b8..0b481ab 100644 --- a/test/settings/components/form/PropertiesForm.test.tsx +++ b/test/settings/components/form/PropertiesForm.test.tsx @@ -1,9 +1,12 @@ +/** + * @jest-environment jsdom + */ + import React from "react"; 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", () => { @@ -25,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); }); }); @@ -57,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(); }} />, @@ -79,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(); }} />, @@ -101,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 7b10274..8b84e12 100644 --- a/test/settings/components/form/SearchEngineForm.test.tsx +++ b/test/settings/components/form/SearchEngineForm.test.tsx @@ -1,10 +1,13 @@ +/** + * @jest-environment jsdom + */ + import React from "react"; import ReactDOM from "react-dom"; 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", () => { @@ -24,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"); }); }); @@ -62,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"], ]); @@ -101,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(); }} />, @@ -129,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"], ["", ""], ]); |