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/settings/components/form/KeymapsForm.test.tsx | |
parent | 685f2b7b69218b06b5bb676069e35f79c5048c9b (diff) |
Use plugin:prettier/recommended
Diffstat (limited to 'test/settings/components/form/KeymapsForm.test.tsx')
-rw-r--r-- | test/settings/components/form/KeymapsForm.test.tsx | 68 |
1 files changed, 39 insertions, 29 deletions
diff --git a/test/settings/components/form/KeymapsForm.test.tsx b/test/settings/components/form/KeymapsForm.test.tsx index ccc772c..0a88db5 100644 --- a/test/settings/components/form/KeymapsForm.test.tsx +++ b/test/settings/components/form/KeymapsForm.test.tsx @@ -1,27 +1,31 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; -import ReactTestRenderer from 'react-test-renderer'; -import ReactTestUtils from 'react-dom/test-utils'; -import KeymapsForm from '../../../../src/settings/components/form/KeymapsForm' -import { FormKeymaps } from 'shared/SettingData'; -import { expect } from 'chai'; +import React from "react"; +import ReactDOM from "react-dom"; +import ReactTestRenderer from "react-test-renderer"; +import ReactTestUtils from "react-dom/test-utils"; +import KeymapsForm from "../../../../src/settings/components/form/KeymapsForm"; +import { FormKeymaps } from "shared/SettingData"; +import { expect } from "chai"; describe("settings/form/KeymapsForm", () => { - describe('render', () => { - it('renders keymap fields', () => { - const root = ReactTestRenderer.create(<KeymapsForm value={FormKeymaps.fromJSON({ - 'scroll.vertically?{"count":1}': 'j', - 'scroll.vertically?{"count":-1}': 'k', - })} />).root + describe("render", () => { + it("renders keymap fields", () => { + const root = ReactTestRenderer.create( + <KeymapsForm + value={FormKeymaps.fromJSON({ + 'scroll.vertically?{"count":1}': "j", + 'scroll.vertically?{"count":-1}': "k", + })} + /> + ).root; const inputj = root.findByProps({ id: 'scroll.vertically?{"count":1}' }); const inputk = root.findByProps({ id: 'scroll.vertically?{"count":-1}' }); - expect(inputj.props.value).to.equal('j'); - expect(inputk.props.value).to.equal('k'); + expect(inputj.props.value).to.equal("j"); + expect(inputk.props.value).to.equal("k"); }); - it('renders blank value', () => { + it("renders blank value", () => { const root = ReactTestRenderer.create(<KeymapsForm />).root; const inputj = root.findByProps({ id: 'scroll.vertically?{"count":1}' }); @@ -32,11 +36,11 @@ describe("settings/form/KeymapsForm", () => { }); }); - describe('onChange event', () => { + describe("onChange event", () => { let container; beforeEach(() => { - container = document.createElement('div'); + container = document.createElement("div"); document.body.appendChild(container); }); @@ -45,21 +49,27 @@ describe("settings/form/KeymapsForm", () => { container = null; }); - it('invokes onChange event on edit', (done) => { + it("invokes onChange event on edit", (done) => { ReactTestUtils.act(() => { - ReactDOM.render(<KeymapsForm - value={FormKeymaps.fromJSON({ - 'scroll.vertically?{"count":1}': 'j', - 'scroll.vertically?{"count":-1}': 'k', - })} - onChange={value => { - expect(value.toJSON()['scroll.vertically?{"count":1}']).to.equal('jjj'); - done(); - }} />, container); + ReactDOM.render( + <KeymapsForm + value={FormKeymaps.fromJSON({ + 'scroll.vertically?{"count":1}': "j", + 'scroll.vertically?{"count":-1}': "k", + })} + onChange={(value) => { + expect(value.toJSON()['scroll.vertically?{"count":1}']).to.equal( + "jjj" + ); + done(); + }} + />, + container + ); }); const input = document.getElementById('scroll.vertically?{"count":1}'); - input.value = 'jjj'; + input.value = "jjj"; ReactTestUtils.Simulate.change(input); }); }); |