From c60d0e7392fc708e961614d6b756a045de74f458 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Tue, 30 Apr 2019 14:00:07 +0900 Subject: Rename .js/.jsx to .ts/.tsx --- .../console/components/console/Completion.test.jsx | 168 --------------------- .../console/components/console/Completion.test.tsx | 168 +++++++++++++++++++++ 2 files changed, 168 insertions(+), 168 deletions(-) delete mode 100644 test/console/components/console/Completion.test.jsx create mode 100644 test/console/components/console/Completion.test.tsx (limited to 'test/console/components') diff --git a/test/console/components/console/Completion.test.jsx b/test/console/components/console/Completion.test.jsx deleted file mode 100644 index 16bf11a..0000000 --- a/test/console/components/console/Completion.test.jsx +++ /dev/null @@ -1,168 +0,0 @@ -import React from 'react'; -import Completion from 'console/components/console/Completion' -import ReactTestRenderer from 'react-test-renderer'; - -describe("console/components/console/completion", () => { - let completions = [{ - name: "Fruit", - items: [{ caption: "apple" }, { caption: "banana" }, { caption: "cherry" }], - }, { - name: "Element", - items: [{ caption: "argon" }, { caption: "boron" }, { caption: "carbon" }], - }]; - - it('renders Completion component', () => { - let root = ReactTestRenderer.create().root; - - expect(root.children).to.have.lengthOf(1); - - let 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'); - }); - - it('highlight current item', () => { - let root = ReactTestRenderer.create().root; - - let children = root.children[0].children; - expect(children[5].props.highlight).to.be.true; - }); - - it('does not highlight any items', () => { - let root = ReactTestRenderer.create().root; - - let children = root.children[0].children; - for (let li of children[0].children) { - expect(li.props.highlight).not.to.be.ok; - } - }); - - it('limits completion items', () => { - let root = ReactTestRenderer.create().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'); - - root = ReactTestRenderer.create().root; - - children = root.children[0].children; - expect(children[1].props.highlight).to.be.true; - }) - - it('scrolls up to down with select', () => { - let component = ReactTestRenderer.create(); - let instance = component.getInstance(); - let 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'); - - component.update(); - - 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[2].props.highlight).to.be.true; - - component.update(); - - 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[2].props.highlight).to.be.true; - }); - - it('scrolls down to up with select', () => { - let component = ReactTestRenderer.create(); - let root = component.root; - let instance = component.getInstance(); - - 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'); - - component.update(); - - children = root.children[0].children; - expect(children[1].props.highlight).to.be.true; - - component.update(); - - children = root.children[0].children; - expect(children[0].props.highlight).to.be.true; - - component.update(); - - 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.highlight).to.be.true; - }); -}); diff --git a/test/console/components/console/Completion.test.tsx b/test/console/components/console/Completion.test.tsx new file mode 100644 index 0000000..16bf11a --- /dev/null +++ b/test/console/components/console/Completion.test.tsx @@ -0,0 +1,168 @@ +import React from 'react'; +import Completion from 'console/components/console/Completion' +import ReactTestRenderer from 'react-test-renderer'; + +describe("console/components/console/completion", () => { + let completions = [{ + name: "Fruit", + items: [{ caption: "apple" }, { caption: "banana" }, { caption: "cherry" }], + }, { + name: "Element", + items: [{ caption: "argon" }, { caption: "boron" }, { caption: "carbon" }], + }]; + + it('renders Completion component', () => { + let root = ReactTestRenderer.create().root; + + expect(root.children).to.have.lengthOf(1); + + let 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'); + }); + + it('highlight current item', () => { + let root = ReactTestRenderer.create().root; + + let children = root.children[0].children; + expect(children[5].props.highlight).to.be.true; + }); + + it('does not highlight any items', () => { + let root = ReactTestRenderer.create().root; + + let children = root.children[0].children; + for (let li of children[0].children) { + expect(li.props.highlight).not.to.be.ok; + } + }); + + it('limits completion items', () => { + let root = ReactTestRenderer.create().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'); + + root = ReactTestRenderer.create().root; + + children = root.children[0].children; + expect(children[1].props.highlight).to.be.true; + }) + + it('scrolls up to down with select', () => { + let component = ReactTestRenderer.create(); + let instance = component.getInstance(); + let 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'); + + component.update(); + + 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[2].props.highlight).to.be.true; + + component.update(); + + 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[2].props.highlight).to.be.true; + }); + + it('scrolls down to up with select', () => { + let component = ReactTestRenderer.create(); + let root = component.root; + let instance = component.getInstance(); + + 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'); + + component.update(); + + children = root.children[0].children; + expect(children[1].props.highlight).to.be.true; + + component.update(); + + children = root.children[0].children; + expect(children[0].props.highlight).to.be.true; + + component.update(); + + 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.highlight).to.be.true; + }); +}); -- cgit v1.2.3