aboutsummaryrefslogtreecommitdiff
path: root/test/console/components
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2021-09-26 17:01:31 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2021-09-26 17:23:14 +0900
commite304581fb15eabb3a973d363a282ee7546561e01 (patch)
tree1afb21a2dee2ada3d10c1417fa61c0aae1f83077 /test/console/components
parent11d6d725eee2ac0a1c16e4c7a4ce4f296bb6b016 (diff)
Do not use chai on unit test
Diffstat (limited to 'test/console/components')
-rw-r--r--test/console/components/ErrorMessage.test.tsx5
-rw-r--r--test/console/components/InfoMessage.test.tsx5
-rw-r--r--test/console/components/console/Completion.test.tsx43
-rw-r--r--test/console/components/console/CompletionItem.test.tsx7
-rw-r--r--test/console/components/console/CompletionTitle.test.tsx3
5 files changed, 29 insertions, 34 deletions
diff --git a/test/console/components/ErrorMessage.test.tsx b/test/console/components/ErrorMessage.test.tsx
index 5097bc1..45b3052 100644
--- a/test/console/components/ErrorMessage.test.tsx
+++ b/test/console/components/ErrorMessage.test.tsx
@@ -1,6 +1,5 @@
import React from "react";
import ReactTestRenderer from "react-test-renderer";
-import { expect } from "chai";
import ErrorMessage from "../../../src/console/components/ErrorMessage";
describe("console/components/console/completion/ErrorMessage", () => {
@@ -11,7 +10,7 @@ describe("console/components/console/completion/ErrorMessage", () => {
const p = root.findByType("p");
- expect(p.props["role"]).to.equal("alert");
- expect(p.children).to.deep.equal(["Hello!"]);
+ expect(p.props["role"]).toEqual("alert");
+ expect(p.children).toEqual(["Hello!"]);
});
});
diff --git a/test/console/components/InfoMessage.test.tsx b/test/console/components/InfoMessage.test.tsx
index 1f8f16d..9f3a68d 100644
--- a/test/console/components/InfoMessage.test.tsx
+++ b/test/console/components/InfoMessage.test.tsx
@@ -1,6 +1,5 @@
import React from "react";
import ReactTestRenderer from "react-test-renderer";
-import { expect } from "chai";
import InfoMessage from "../../../src/console/components/InfoMessage";
describe("console/components/console/completion/InfoMessage", () => {
@@ -11,7 +10,7 @@ describe("console/components/console/completion/InfoMessage", () => {
const p = root.findByType("p");
- expect(p.props["role"]).to.equal("status");
- expect(p.children).to.deep.equal(["Hello!"]);
+ expect(p.props["role"]).toEqual("status");
+ expect(p.children).toEqual(["Hello!"]);
});
});
diff --git a/test/console/components/console/Completion.test.tsx b/test/console/components/console/Completion.test.tsx
index 063b1e3..7dd634f 100644
--- a/test/console/components/console/Completion.test.tsx
+++ b/test/console/components/console/Completion.test.tsx
@@ -1,7 +1,6 @@
import React from "react";
import Completion from "../../../../src/console/components/console/Completion";
import ReactTestRenderer from "react-test-renderer";
-import { expect } from "chai";
import CompletionTitle from "../../../../src/console/components/console/CompletionTitle";
import CompletionItem from "../../../../src/console/components/console/CompletionItem";
@@ -31,16 +30,16 @@ describe("console/components/console/completion/Completion", () => {
).root;
const groups = root.findAllByProps({ role: "group" });
- expect(groups).to.have.lengthOf(2);
+ expect(groups).toHaveLength(2);
groups.forEach((group, i) => {
const title = group.findByType(CompletionTitle);
- expect(title.props.title).to.equal(completions[i].name);
+ expect(title.props.title).toEqual(completions[i].name);
const items = group.findAllByType(CompletionItem);
- expect(items).to.have.lengthOf(completions[i].items.length);
+ expect(items).toHaveLength(completions[i].items.length);
items.forEach((item, j) => {
- expect(item.props.caption).to.equal(completions[i].items[j].caption);
+ expect(item.props.caption).toEqual(completions[i].items[j].caption);
});
});
});
@@ -51,7 +50,7 @@ describe("console/components/console/completion/Completion", () => {
).root;
const items = root.findAllByType(CompletionItem);
- expect(items[3].props.highlight).to.be.true;
+ expect(items[3].props.highlight).toBeTruthy;
});
it("does not highlight any items", () => {
@@ -60,7 +59,7 @@ describe("console/components/console/completion/Completion", () => {
).root;
const items = root.findAllByType(CompletionItem);
- expect(items.every((item) => item.props.highlight === false)).to.be.true;
+ expect(items.every((item) => item.props.highlight === false)).toBeTruthy;
});
it("limits completion items", () => {
@@ -78,7 +77,7 @@ describe("console/components/console/completion/Completion", () => {
)
.flat();
- expect(showns).to.deep.equal([
+ expect(showns).toEqual([
true,
true,
true,
@@ -96,7 +95,7 @@ describe("console/components/console/completion/Completion", () => {
const items = root
.findAllByType(CompletionItem)
.map((item) => item.props.shown);
- expect(items[1]).to.be.true;
+ expect(items[1]).toBeTruthy;
});
it("scrolls up to down with select", () => {
@@ -120,7 +119,7 @@ describe("console/components/console/completion/Completion", () => {
].flat()
)
.flat();
- expect(showns).to.deep.equal([
+ expect(showns).toEqual([
true,
true,
true,
@@ -146,7 +145,7 @@ describe("console/components/console/completion/Completion", () => {
].flat()
)
.flat();
- expect(showns).to.deep.equal([
+ expect(showns).toEqual([
false,
true,
true,
@@ -156,7 +155,7 @@ describe("console/components/console/completion/Completion", () => {
false,
false,
]);
- expect(items[2].props.highlight).to.be.true;
+ expect(items[2].props.highlight).toBeTruthy;
ReactTestRenderer.act(() => {
component!.update(
@@ -173,7 +172,7 @@ describe("console/components/console/completion/Completion", () => {
].flat()
)
.flat();
- expect(showns).to.deep.equal([
+ expect(showns).toEqual([
false,
false,
false,
@@ -183,7 +182,7 @@ describe("console/components/console/completion/Completion", () => {
false,
false,
]);
- expect(items[3].props.highlight).to.be.true;
+ expect(items[3].props.highlight).toBeTruthy;
});
it("scrolls down to up with select", () => {
@@ -207,7 +206,7 @@ describe("console/components/console/completion/Completion", () => {
)
.flat();
- expect(showns).to.deep.equal([
+ expect(showns).toEqual([
false,
false,
false,
@@ -217,7 +216,7 @@ describe("console/components/console/completion/Completion", () => {
true,
true,
]);
- expect(items[5].props.highlight).to.be.true;
+ expect(items[5].props.highlight).toBeTruthy;
ReactTestRenderer.act(() => {
component!.update(
@@ -234,7 +233,7 @@ describe("console/components/console/completion/Completion", () => {
].flat()
)
.flat();
- expect(showns).to.deep.equal([
+ expect(showns).toEqual([
false,
false,
false,
@@ -244,7 +243,7 @@ describe("console/components/console/completion/Completion", () => {
true,
true,
]);
- expect(items[4].props.highlight).to.be.true;
+ expect(items[4].props.highlight).toBeTruthy;
ReactTestRenderer.act(() => {
component!.update(
@@ -261,7 +260,7 @@ describe("console/components/console/completion/Completion", () => {
].flat()
)
.flat();
- expect(showns).to.deep.equal([
+ expect(showns).toEqual([
false,
false,
false,
@@ -271,7 +270,7 @@ describe("console/components/console/completion/Completion", () => {
true,
true,
]);
- expect(items[3].props.highlight).to.be.true;
+ expect(items[3].props.highlight).toBeTruthy;
ReactTestRenderer.act(() => {
component!.update(
@@ -288,7 +287,7 @@ describe("console/components/console/completion/Completion", () => {
].flat()
)
.flat();
- expect(showns).to.deep.equal([
+ expect(showns).toEqual([
false,
false,
false,
@@ -298,6 +297,6 @@ describe("console/components/console/completion/Completion", () => {
false,
false,
]);
- expect(items[2].props.highlight).to.be.true;
+ expect(items[2].props.highlight).toBeTruthy;
});
});
diff --git a/test/console/components/console/CompletionItem.test.tsx b/test/console/components/console/CompletionItem.test.tsx
index 3a4b1f2..ae73b21 100644
--- a/test/console/components/console/CompletionItem.test.tsx
+++ b/test/console/components/console/CompletionItem.test.tsx
@@ -1,6 +1,5 @@
import React from "react";
import ReactTestRenderer from "react-test-renderer";
-import { expect } from "chai";
import CompletionItem from "../../../../src/console/components/console/CompletionItem";
describe("console/components/console/completion/CompletionItem", () => {
@@ -14,8 +13,8 @@ describe("console/components/console/completion/CompletionItem", () => {
/>
).root;
const spans = root.findAllByType("span");
- expect(spans).to.have.lengthOf(2);
- expect(spans[0].children).to.deep.equal(["twitter"]);
- expect(spans[1].children).to.deep.equal(["https://twitter.com/"]);
+ expect(spans).toHaveLength(2);
+ expect(spans[0].children).toEqual(["twitter"]);
+ expect(spans[1].children).toEqual(["https://twitter.com/"]);
});
});
diff --git a/test/console/components/console/CompletionTitle.test.tsx b/test/console/components/console/CompletionTitle.test.tsx
index d8cc411..5843c43 100644
--- a/test/console/components/console/CompletionTitle.test.tsx
+++ b/test/console/components/console/CompletionTitle.test.tsx
@@ -1,6 +1,5 @@
import React from "react";
import ReactTestRenderer from "react-test-renderer";
-import { expect } from "chai";
import CompletionTitle from "../../../../src/console/components/console/CompletionTitle";
describe("console/components/console/completion/CompletionTitle", () => {
@@ -10,6 +9,6 @@ describe("console/components/console/completion/CompletionTitle", () => {
).root;
const li = root.findByType("li");
- expect(li.children).to.deep.equal(["Fruits"]);
+ expect(li.children).toEqual(["Fruits"]);
});
});