diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2020-04-13 20:37:36 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2020-04-13 20:37:36 +0900 |
commit | e1dac618a8b8929f601c7ec8aca3842c5ebf9d03 (patch) | |
tree | 6a914a8243c8c02e7752a83667a54d3fa832955c /test/console/components | |
parent | 685f2b7b69218b06b5bb676069e35f79c5048c9b (diff) |
Use plugin:prettier/recommended
Diffstat (limited to 'test/console/components')
-rw-r--r-- | test/console/components/console/Completion.test.tsx | 195 |
1 files changed, 92 insertions, 103 deletions
diff --git a/test/console/components/console/Completion.test.tsx b/test/console/components/console/Completion.test.tsx index e411c4a..200bb1a 100644 --- a/test/console/components/console/Completion.test.tsx +++ b/test/console/components/console/Completion.test.tsx @@ -1,53 +1,59 @@ -import React from 'react'; -import Completion from 'console/components/console/Completion' -import ReactTestRenderer from 'react-test-renderer'; +import React from "react"; +import Completion from "console/components/console/Completion"; +import ReactTestRenderer from "react-test-renderer"; describe("console/components/console/completion", () => { - const completions = [{ - name: "Fruit", - items: [{ caption: "apple" }, { caption: "banana" }, { caption: "cherry" }], - }, { - name: "Element", - items: [{ caption: "argon" }, { caption: "boron" }, { caption: "carbon" }], - }]; - - it('renders Completion component', () => { - const root = ReactTestRenderer.create(<Completion - completions={completions} - size={30} - />).root; + const completions = [ + { + name: "Fruit", + items: [ + { caption: "apple" }, + { caption: "banana" }, + { caption: "cherry" }, + ], + }, + { + name: "Element", + items: [ + { caption: "argon" }, + { caption: "boron" }, + { caption: "carbon" }, + ], + }, + ]; + + it("renders Completion component", () => { + const root = ReactTestRenderer.create( + <Completion completions={completions} size={30} /> + ).root; expect(root.children).to.have.lengthOf(1); const children = root.children[0].children; expect(children).to.have.lengthOf(8); - expect(children[0].props.title).to.equal('Fruit'); - expect(children[1].props.caption).to.equal('apple'); - expect(children[2].props.caption).to.equal('banana'); - expect(children[3].props.caption).to.equal('cherry'); - expect(children[4].props.title).to.equal('Element'); - expect(children[5].props.caption).to.equal('argon'); - expect(children[6].props.caption).to.equal('boron'); - expect(children[7].props.caption).to.equal('carbon'); + expect(children[0].props.title).to.equal("Fruit"); + expect(children[1].props.caption).to.equal("apple"); + expect(children[2].props.caption).to.equal("banana"); + expect(children[3].props.caption).to.equal("cherry"); + expect(children[4].props.title).to.equal("Element"); + expect(children[5].props.caption).to.equal("argon"); + expect(children[6].props.caption).to.equal("boron"); + expect(children[7].props.caption).to.equal("carbon"); }); - it('highlight current item', () => { - const root = ReactTestRenderer.create(<Completion - completions={completions} - size={30} - select={3} - />).root; + it("highlight current item", () => { + const root = ReactTestRenderer.create( + <Completion completions={completions} size={30} select={3} /> + ).root; const children = root.children[0].children; expect(children[5].props.highlight).to.be.true; }); - it('does not highlight any items', () => { - const root = ReactTestRenderer.create(<Completion - completions={completions} - size={30} - select={-1} - />).root; + it("does not highlight any items", () => { + const root = ReactTestRenderer.create( + <Completion completions={completions} size={30} select={-1} /> + ).root; const children = root.children[0].children; for (const li of children[0].children) { @@ -55,112 +61,95 @@ describe("console/components/console/completion", () => { } }); - it('limits completion items', () => { - let root = ReactTestRenderer.create(<Completion - completions={completions} - size={3} - select={-1} - />).root; + it("limits completion items", () => { + let root = ReactTestRenderer.create( + <Completion completions={completions} size={3} select={-1} /> + ).root; let children = root.children[0].children; expect(children).to.have.lengthOf(3); - expect(children[0].props.title).to.equal('Fruit'); - expect(children[1].props.caption).to.equal('apple'); - expect(children[2].props.caption).to.equal('banana'); + expect(children[0].props.title).to.equal("Fruit"); + expect(children[1].props.caption).to.equal("apple"); + expect(children[2].props.caption).to.equal("banana"); - root = ReactTestRenderer.create(<Completion - completions={completions} - size={3} select={0} - />).root; + root = ReactTestRenderer.create( + <Completion completions={completions} size={3} select={0} /> + ).root; children = root.children[0].children; expect(children[1].props.highlight).to.be.true; - }) - - it('scrolls up to down with select', () => { - const component = ReactTestRenderer.create(<Completion - completions={completions} - size={3} - select={1} - />); + }); + + it("scrolls up to down with select", () => { + const component = ReactTestRenderer.create( + <Completion completions={completions} size={3} select={1} /> + ); const root = component.root; let children = root.children[0].children; expect(children).to.have.lengthOf(3); - expect(children[0].props.title).to.equal('Fruit'); - expect(children[1].props.caption).to.equal('apple'); - expect(children[2].props.caption).to.equal('banana'); + expect(children[0].props.title).to.equal("Fruit"); + expect(children[1].props.caption).to.equal("apple"); + expect(children[2].props.caption).to.equal("banana"); - component.update(<Completion - completions={completions} - size={3} - select={2} - />); + component.update( + <Completion completions={completions} size={3} select={2} /> + ); children = root.children[0].children; expect(children).to.have.lengthOf(3); - expect(children[0].props.caption).to.equal('apple'); - expect(children[1].props.caption).to.equal('banana'); - expect(children[2].props.caption).to.equal('cherry'); + expect(children[0].props.caption).to.equal("apple"); + expect(children[1].props.caption).to.equal("banana"); + expect(children[2].props.caption).to.equal("cherry"); expect(children[2].props.highlight).to.be.true; - component.update(<Completion - completions={completions} - size={3} - select={3} - />); + component.update( + <Completion completions={completions} size={3} select={3} /> + ); children = root.children[0].children; expect(children).to.have.lengthOf(3); - expect(children[0].props.caption).to.equal('cherry'); - expect(children[1].props.title).to.equal('Element'); - expect(children[2].props.caption).to.equal('argon'); + expect(children[0].props.caption).to.equal("cherry"); + expect(children[1].props.title).to.equal("Element"); + expect(children[2].props.caption).to.equal("argon"); expect(children[2].props.highlight).to.be.true; }); - it('scrolls down to up with select', () => { - const component = ReactTestRenderer.create(<Completion - completions={completions} - size={3} - select={5} - />); + it("scrolls down to up with select", () => { + const component = ReactTestRenderer.create( + <Completion completions={completions} size={3} select={5} /> + ); const root = component.root; let children = root.children[0].children; expect(children).to.have.lengthOf(3); - expect(children[0].props.caption).to.equal('argon'); - expect(children[1].props.caption).to.equal('boron'); - expect(children[2].props.caption).to.equal('carbon'); + expect(children[0].props.caption).to.equal("argon"); + expect(children[1].props.caption).to.equal("boron"); + expect(children[2].props.caption).to.equal("carbon"); - component.update(<Completion - completions={completions} - size={3} - select={4} - />); + component.update( + <Completion completions={completions} size={3} select={4} /> + ); children = root.children[0].children; expect(children[1].props.highlight).to.be.true; - component.update(<Completion - completions={completions} - size={3} - select={3} - />); + component.update( + <Completion completions={completions} size={3} select={3} /> + ); children = root.children[0].children; expect(children[0].props.highlight).to.be.true; - component.update(<Completion - completions={completions} - size={3} - select={2} - />); + component.update( + <Completion completions={completions} size={3} select={2} /> + ); children = root.children[0].children; - expect(children[0].props.caption).to.equal('cherry'); - expect(children[1].props.title).to.equal('Element'); - expect(children[2].props.caption).to.equal('argon'); + expect(children[0].props.caption).to.equal("cherry"); + expect(children[1].props.title).to.equal("Element"); + expect(children[2].props.caption).to.equal("argon"); expect(children[0].props.highlight).to.be.true; }); }); |