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 --- test/settings/components/ui/input.test.jsx | 111 ----------------------------- test/settings/components/ui/input.test.tsx | 111 +++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+), 111 deletions(-) delete mode 100644 test/settings/components/ui/input.test.jsx create mode 100644 test/settings/components/ui/input.test.tsx (limited to 'test/settings/components/ui') diff --git a/test/settings/components/ui/input.test.jsx b/test/settings/components/ui/input.test.jsx deleted file mode 100644 index 432efcb..0000000 --- a/test/settings/components/ui/input.test.jsx +++ /dev/null @@ -1,111 +0,0 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; -import ReactTestUtils from 'react-dom/test-utils'; -import Input from 'settings/components/ui/Input' - -describe("settings/ui/Input", () => { - let container; - - beforeEach(() => { - container = document.createElement('div'); - document.body.appendChild(container); - }); - - afterEach(() => { - document.body.removeChild(container); - container = null; - }); - - context("type=text", () => { - it('renders text input', () => { - ReactTestUtils.act(() => { - ReactDOM.render( - , - container); - }); - - let label = document.querySelector('label'); - let 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'); - }); - - it('invoke onChange', (done) => { - ReactTestUtils.act(() => { - ReactDOM.render( { - expect(e.target.value).to.equal('newvalue'); - done(); - }}/>, container); - }); - - let input = document.querySelector('input'); - input.value = 'newvalue'; - ReactTestUtils.Simulate.change(input); - }); - }); - - context("type=radio", () => { - it('renders radio button', () => { - ReactTestUtils.act(() => { - ReactDOM.render( - , - container); - }); - - let label = document.querySelector('label'); - let input = document.querySelector('input'); - expect(label.textContent).to.contain('myfield'); - expect(input.type).to.contain('radio'); - expect(input.name).to.contain('myname'); - expect(input.value).to.contain('myvalue'); - }); - - it('invoke onChange', (done) => { - ReactTestUtils.act(() => { - ReactDOM.render( { - expect(e.target.checked).to.be.true; - done(); - }}/>, - container); - }); - - let input = document.querySelector('input'); - input.checked = true; - ReactTestUtils.Simulate.change(input); - }); - }); - - context("type=textarea", () => { - it('renders textarea button', () => { - ReactTestUtils.act(() => { - ReactDOM.render( - , - container); - }); - - let label = document.querySelector('label'); - let textarea = document.querySelector('textarea'); - let error = document.querySelector('.settings-ui-input-error'); - 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'); - }); - - it('invoke onChange', (done) => { - ReactTestUtils.act(() => { - ReactDOM.render( { - expect(e.target.value).to.equal('newvalue'); - done(); - }}/>, container); - }); - - let input = document.querySelector('textarea'); - input.value = 'newvalue' - ReactTestUtils.Simulate.change(input); - }); - }); -}); diff --git a/test/settings/components/ui/input.test.tsx b/test/settings/components/ui/input.test.tsx new file mode 100644 index 0000000..432efcb --- /dev/null +++ b/test/settings/components/ui/input.test.tsx @@ -0,0 +1,111 @@ +import React from 'react'; +import ReactDOM from 'react-dom'; +import ReactTestUtils from 'react-dom/test-utils'; +import Input from 'settings/components/ui/Input' + +describe("settings/ui/Input", () => { + let container; + + beforeEach(() => { + container = document.createElement('div'); + document.body.appendChild(container); + }); + + afterEach(() => { + document.body.removeChild(container); + container = null; + }); + + context("type=text", () => { + it('renders text input', () => { + ReactTestUtils.act(() => { + ReactDOM.render( + , + container); + }); + + let label = document.querySelector('label'); + let 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'); + }); + + it('invoke onChange', (done) => { + ReactTestUtils.act(() => { + ReactDOM.render( { + expect(e.target.value).to.equal('newvalue'); + done(); + }}/>, container); + }); + + let input = document.querySelector('input'); + input.value = 'newvalue'; + ReactTestUtils.Simulate.change(input); + }); + }); + + context("type=radio", () => { + it('renders radio button', () => { + ReactTestUtils.act(() => { + ReactDOM.render( + , + container); + }); + + let label = document.querySelector('label'); + let input = document.querySelector('input'); + expect(label.textContent).to.contain('myfield'); + expect(input.type).to.contain('radio'); + expect(input.name).to.contain('myname'); + expect(input.value).to.contain('myvalue'); + }); + + it('invoke onChange', (done) => { + ReactTestUtils.act(() => { + ReactDOM.render( { + expect(e.target.checked).to.be.true; + done(); + }}/>, + container); + }); + + let input = document.querySelector('input'); + input.checked = true; + ReactTestUtils.Simulate.change(input); + }); + }); + + context("type=textarea", () => { + it('renders textarea button', () => { + ReactTestUtils.act(() => { + ReactDOM.render( + , + container); + }); + + let label = document.querySelector('label'); + let textarea = document.querySelector('textarea'); + let error = document.querySelector('.settings-ui-input-error'); + 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'); + }); + + it('invoke onChange', (done) => { + ReactTestUtils.act(() => { + ReactDOM.render( { + expect(e.target.value).to.equal('newvalue'); + done(); + }}/>, container); + }); + + let input = document.querySelector('textarea'); + input.value = 'newvalue' + ReactTestUtils.Simulate.change(input); + }); + }); +}); -- cgit v1.2.3