aboutsummaryrefslogtreecommitdiff
path: root/test/settings/components/form/KeymapsForm.test.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'test/settings/components/form/KeymapsForm.test.tsx')
-rw-r--r--test/settings/components/form/KeymapsForm.test.tsx75
1 files changed, 43 insertions, 32 deletions
diff --git a/test/settings/components/form/KeymapsForm.test.tsx b/test/settings/components/form/KeymapsForm.test.tsx
index ccc772c..1cec889 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 "../../../../src/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,34 +36,41 @@ describe("settings/form/KeymapsForm", () => {
});
});
- describe('onChange event', () => {
- let container;
+ describe("onChange event", () => {
+ let container: HTMLDivElement;
beforeEach(() => {
- container = document.createElement('div');
+ container = document.createElement("div");
document.body.appendChild(container);
});
afterEach(() => {
document.body.removeChild(container);
- 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';
+ const input = document.getElementById(
+ 'scroll.vertically?{"count":1}'
+ ) as HTMLInputElement;
+ input.value = "jjj";
ReactTestUtils.Simulate.change(input);
});
});