aboutsummaryrefslogtreecommitdiff
path: root/test/settings/components
diff options
context:
space:
mode:
Diffstat (limited to 'test/settings/components')
-rw-r--r--test/settings/components/form/BlacklistForm.test.tsx24
-rw-r--r--test/settings/components/form/KeymapsForm.test.tsx15
-rw-r--r--test/settings/components/form/PropertiesForm.test.tsx23
-rw-r--r--test/settings/components/form/SearchEngineForm.test.tsx37
-rw-r--r--test/settings/components/ui/Radio.test.tsx15
-rw-r--r--test/settings/components/ui/Text.test.tsx15
-rw-r--r--test/settings/components/ui/TextArea.test.tsx18
7 files changed, 81 insertions, 66 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"],
["", ""],
]);
diff --git a/test/settings/components/ui/Radio.test.tsx b/test/settings/components/ui/Radio.test.tsx
index f929ee3..e2bf214 100644
--- a/test/settings/components/ui/Radio.test.tsx
+++ b/test/settings/components/ui/Radio.test.tsx
@@ -1,8 +1,11 @@
+/**
+ * @jest-environment jsdom
+ */
+
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;
@@ -26,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) => {
@@ -41,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 d5451bb..a8e0bf9 100644
--- a/test/settings/components/ui/Text.test.tsx
+++ b/test/settings/components/ui/Text.test.tsx
@@ -1,8 +1,11 @@
+/**
+ * @jest-environment jsdom
+ */
+
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;
@@ -26,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) => {
@@ -40,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 232c7c0..76caec2 100644
--- a/test/settings/components/ui/TextArea.test.tsx
+++ b/test/settings/components/ui/TextArea.test.tsx
@@ -1,8 +1,11 @@
+/**
+ * @jest-environment jsdom
+ */
+
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;
@@ -20,7 +23,6 @@ describe("settings/ui/TextArea", () => {
ReactTestUtils.act(() => {
ReactDOM.render(
<TextArea
- type="textarea"
name="myname"
label="myfield"
value="myvalue"
@@ -33,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) => {
@@ -48,7 +50,7 @@ describe("settings/ui/TextArea", () => {
label="myfield"
value="myvalue"
onChange={(e) => {
- expect((e.target as HTMLInputElement).value).to.equal("newvalue");
+ expect((e.target as HTMLTextAreaElement).value).toEqual("newvalue");
done();
}}
/>,