diff options
Diffstat (limited to 'test/console')
-rw-r--r-- | test/console/app/actions.test.ts | 19 | ||||
-rw-r--r-- | test/console/app/reducer.test.ts | 21 | ||||
-rw-r--r-- | test/console/commandline/CommandLineParser.test.ts | 13 | ||||
-rw-r--r-- | test/console/commandline/CommandParser.test.ts | 9 | ||||
-rw-r--r-- | test/console/completion/reducer.test.ts | 31 | ||||
-rw-r--r-- | test/console/components/ErrorMessage.test.tsx | 5 | ||||
-rw-r--r-- | test/console/components/InfoMessage.test.tsx | 5 | ||||
-rw-r--r-- | test/console/components/console/Completion.test.tsx | 43 | ||||
-rw-r--r-- | test/console/components/console/CompletionItem.test.tsx | 7 | ||||
-rw-r--r-- | test/console/components/console/CompletionTitle.test.tsx | 3 |
10 files changed, 73 insertions, 83 deletions
diff --git a/test/console/app/actions.test.ts b/test/console/app/actions.test.ts index 2f9dc71..d4b4568 100644 --- a/test/console/app/actions.test.ts +++ b/test/console/app/actions.test.ts @@ -7,7 +7,6 @@ import { SHOW_FIND, SHOW_INFO, } from "../../../src/console/app/actions"; -import { expect } from "chai"; import browserFake from "webextensions-api-fake"; @@ -19,44 +18,44 @@ describe("console actions", () => { describe("hide", () => { it("create CONSOLE_HIDE action", () => { const action = consoleActions.hide(); - expect(action.type).to.equal(HIDE); + expect(action.type).toEqual(HIDE); }); }); describe("showCommand", () => { it("create CONSOLE_SHOW_COMMAND action", async () => { const action = await consoleActions.showCommand("hello"); - expect(action.type).to.equal(SHOW_COMMAND); - expect(action.text).to.equal("hello"); + expect(action.type).toEqual(SHOW_COMMAND); + expect(action.text).toEqual("hello"); }); }); describe("showFind", () => { it("create CONSOLE_SHOW_FIND action", () => { const action = consoleActions.showFind(); - expect(action.type).to.equal(SHOW_FIND); + expect(action.type).toEqual(SHOW_FIND); }); }); describe("showError", () => { it("create CONSOLE_SHOW_ERROR action", () => { const action = consoleActions.showError("an error"); - expect(action.type).to.equal(SHOW_ERROR); - expect(action.text).to.equal("an error"); + expect(action.type).toEqual(SHOW_ERROR); + expect(action.text).toEqual("an error"); }); }); describe("showInfo", () => { it("create CONSOLE_SHOW_INFO action", () => { const action = consoleActions.showInfo("an info"); - expect(action.type).to.equal(SHOW_INFO); - expect(action.text).to.equal("an info"); + expect(action.type).toEqual(SHOW_INFO); + expect(action.text).toEqual("an info"); }); }); describe("hideCommand", () => { it("create CONSOLE_HIDE_COMMAND action", () => { const action = consoleActions.hideCommand(); - expect(action.type).to.equal(HIDE_COMMAND); + expect(action.type).toEqual(HIDE_COMMAND); }); }); }); diff --git a/test/console/app/reducer.test.ts b/test/console/app/reducer.test.ts index 4406adc..eac2012 100644 --- a/test/console/app/reducer.test.ts +++ b/test/console/app/reducer.test.ts @@ -1,4 +1,3 @@ -import { expect } from "chai"; import reducer, { defaultState, State } from "../../../src/console/app/recuer"; import { hide, @@ -18,7 +17,7 @@ describe("app reducer", () => { }; const nextState = reducer(initialState, hide()); - expect(nextState.mode).to.be.empty; + expect(nextState.mode).toHaveLength(0); }); }); @@ -26,8 +25,8 @@ describe("app reducer", () => { it("switches to command mode with a message", () => { const nextState = reducer(defaultState, showCommand("open ")); - expect(nextState.mode).equals("command"); - expect(nextState.consoleText).equals("open "); + expect(nextState.mode).toEqual("command"); + expect(nextState.consoleText).toEqual("open "); }); }); @@ -35,7 +34,7 @@ describe("app reducer", () => { it("switches to find mode with a message", () => { const nextState = reducer(defaultState, showFind()); - expect(nextState.mode).equals("find"); + expect(nextState.mode).toEqual("find"); }); }); @@ -43,8 +42,8 @@ describe("app reducer", () => { it("switches to error message mode with a message", () => { const nextState = reducer(defaultState, showError("error occurs")); - expect(nextState.mode).equals("error"); - expect(nextState.messageText).equals("error occurs"); + expect(nextState.mode).toEqual("error"); + expect(nextState.messageText).toEqual("error occurs"); }); }); @@ -52,8 +51,8 @@ describe("app reducer", () => { it("switches to info message mode with a message", () => { const nextState = reducer(defaultState, showInfo("what's up")); - expect(nextState.mode).equals("info"); - expect(nextState.messageText).equals("what's up"); + expect(nextState.mode).toEqual("info"); + expect(nextState.messageText).toEqual("what's up"); }); }); @@ -66,7 +65,7 @@ describe("app reducer", () => { }; const nextState = reducer(initialState, hideCommand()); - expect(nextState.mode).to.be.empty; + expect(nextState.mode).toHaveLength(0); }); }); @@ -78,7 +77,7 @@ describe("app reducer", () => { }; const nextState = reducer(initialState, hideCommand()); - expect(nextState.mode).equals("info"); + expect(nextState.mode).toEqual("info"); }); }); }); diff --git a/test/console/commandline/CommandLineParser.test.ts b/test/console/commandline/CommandLineParser.test.ts index 7cba04c..d187e1e 100644 --- a/test/console/commandline/CommandLineParser.test.ts +++ b/test/console/commandline/CommandLineParser.test.ts @@ -2,27 +2,26 @@ import CommandLineParser, { InputPhase, } from "../../../src/console/commandline/CommandLineParser"; import { Command } from "../../../src/shared/Command"; -import { expect } from "chai"; describe("CommandLineParser", () => { describe("#inputPhase", () => { it("returns parsed command-line", () => { const sut = new CommandLineParser(); - expect(sut.inputPhase("")).to.equal(InputPhase.OnCommand); - expect(sut.inputPhase("op")).to.equal(InputPhase.OnCommand); - expect(sut.inputPhase("open ")).to.equal(InputPhase.OnArgs); - expect(sut.inputPhase("open apple")).to.equal(InputPhase.OnArgs); + expect(sut.inputPhase("")).toEqual(InputPhase.OnCommand); + expect(sut.inputPhase("op")).toEqual(InputPhase.OnCommand); + expect(sut.inputPhase("open ")).toEqual(InputPhase.OnArgs); + expect(sut.inputPhase("open apple")).toEqual(InputPhase.OnArgs); }); }); describe("#parse", () => { it("returns parsed command-line", () => { const sut = new CommandLineParser(); - expect(sut.parse("open google apple")).to.deep.equal({ + expect(sut.parse("open google apple")).toEqual({ command: Command.Open, args: "google apple", }); - expect(sut.parse("qa")).to.deep.equal({ + expect(sut.parse("qa")).toEqual({ command: Command.QuitAll, args: "", }); diff --git a/test/console/commandline/CommandParser.test.ts b/test/console/commandline/CommandParser.test.ts index f72afd6..a8e82df 100644 --- a/test/console/commandline/CommandParser.test.ts +++ b/test/console/commandline/CommandParser.test.ts @@ -2,16 +2,15 @@ import CommandParser, { UnknownCommandError, } from "../../../src/console/commandline/CommandParser"; import { Command } from "../../../src/shared/Command"; -import { expect } from "chai"; describe("CommandParser", () => { describe("#parse", () => { it("returns matched command with the string", () => { const sut = new CommandParser(); - expect(sut.parse("open")).to.equal(Command.Open); - expect(sut.parse("w")).to.equal(Command.WindowOpen); - expect(sut.parse("bdelete!")).to.equal(Command.BufferDeleteForce); - expect(() => sut.parse("harakiri")).to.throw(UnknownCommandError); + expect(sut.parse("open")).toEqual(Command.Open); + expect(sut.parse("w")).toEqual(Command.WindowOpen); + expect(sut.parse("bdelete!")).toEqual(Command.BufferDeleteForce); + expect(() => sut.parse("harakiri")).toThrow(UnknownCommandError); }); }); }); diff --git a/test/console/completion/reducer.test.ts b/test/console/completion/reducer.test.ts index 91a6751..43b9807 100644 --- a/test/console/completion/reducer.test.ts +++ b/test/console/completion/reducer.test.ts @@ -2,7 +2,6 @@ import reducer, { defaultState, State, } from "../../../src/console/completion/reducer"; -import { expect } from "chai"; import { initCompletion, selectNext, @@ -20,7 +19,7 @@ describe("completion reducer", () => { initCompletion([CompletionType.Bookmarks, CompletionType.History]) ); - expect(nextState.completionTypes).deep.equals([ + expect(nextState.completionTypes).toEqual([ CompletionType.Bookmarks, CompletionType.History, ]); @@ -31,7 +30,7 @@ describe("completion reducer", () => { it("sets a completion source", () => { const nextState = reducer(defaultState, setCompletionSource("open ")); - expect(nextState.completionSource).equals("open "); + expect(nextState.completionSource).toEqual("open "); }); }); @@ -51,7 +50,7 @@ describe("completion reducer", () => { ]) ); - expect(nextState.completions).deep.equals([ + expect(nextState.completions).toEqual([ { name: "Apple", items: [{}, {}], @@ -68,7 +67,7 @@ describe("completion reducer", () => { describe("when no completion groups", () => { it("does nothing", () => { const nextState = reducer(defaultState, selectNext()); - expect(nextState.select).equals(-1); + expect(nextState.select).toEqual(-1); }); }); @@ -79,7 +78,7 @@ describe("completion reducer", () => { completions: [{ name: "apple", items: [] }], }; const nextState = reducer(state, selectNext()); - expect(nextState.select).equals(-1); + expect(nextState.select).toEqual(-1); }); }); @@ -101,16 +100,16 @@ describe("completion reducer", () => { }; state = reducer(state, selectNext()); - expect(state.select).equals(0); + expect(state.select).toEqual(0); state = reducer(state, selectNext()); - expect(state.select).equals(1); + expect(state.select).toEqual(1); state = reducer(state, selectNext()); - expect(state.select).equals(2); + expect(state.select).toEqual(2); state = reducer(state, selectNext()); - expect(state.select).equals(-1); + expect(state.select).toEqual(-1); }); }); }); @@ -119,7 +118,7 @@ describe("completion reducer", () => { describe("when no completion groups", () => { it("does nothing", () => { const nextState = reducer(defaultState, selectPrev()); - expect(nextState.select).equals(-1); + expect(nextState.select).toEqual(-1); }); describe("when no completion items", () => { @@ -129,7 +128,7 @@ describe("completion reducer", () => { completions: [{ name: "apple", items: [] }], }; const nextState = reducer(state, selectPrev()); - expect(nextState.select).equals(-1); + expect(nextState.select).toEqual(-1); }); }); }); @@ -152,16 +151,16 @@ describe("completion reducer", () => { }; state = reducer(state, selectPrev()); - expect(state).to.have.property("select", 2); + expect(state).toHaveProperty("select", 2); state = reducer(state, selectPrev()); - expect(state).to.have.property("select", 1); + expect(state).toHaveProperty("select", 1); state = reducer(state, selectPrev()); - expect(state).to.have.property("select", 0); + expect(state).toHaveProperty("select", 0); state = reducer(state, selectPrev()); - expect(state).to.have.property("select", -1); + expect(state).toHaveProperty("select", -1); }); }); }); 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"]); }); }); |