aboutsummaryrefslogtreecommitdiff
path: root/test/settings/components/form/PropertiesForm.test.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'test/settings/components/form/PropertiesForm.test.tsx')
-rw-r--r--test/settings/components/form/PropertiesForm.test.tsx121
1 files changed, 65 insertions, 56 deletions
diff --git a/test/settings/components/form/PropertiesForm.test.tsx b/test/settings/components/form/PropertiesForm.test.tsx
index 4a0e25a..4dc00a2 100644
--- a/test/settings/components/form/PropertiesForm.test.tsx
+++ b/test/settings/components/form/PropertiesForm.test.tsx
@@ -1,47 +1,47 @@
-import React from 'react';
-import ReactDOM from 'react-dom';
-import ReactTestRenderer from 'react-test-renderer';
-import ReactTestUtils from 'react-dom/test-utils';
-import PropertiesForm from 'settings/components/form/PropertiesForm'
+import React from "react";
+import ReactDOM from "react-dom";
+import ReactTestRenderer from "react-test-renderer";
+import ReactTestUtils from "react-dom/test-utils";
+import PropertiesForm from "settings/components/form/PropertiesForm";
describe("settings/form/PropertiesForm", () => {
- describe('render', () => {
- it('renders PropertiesForm', () => {
+ describe("render", () => {
+ it("renders PropertiesForm", () => {
const types = {
- mystr: 'string',
- mynum: 'number',
- mybool: 'boolean',
- empty: 'string',
- }
+ mystr: "string",
+ mynum: "number",
+ mybool: "boolean",
+ empty: "string",
+ };
const values = {
- mystr: 'abc',
+ mystr: "abc",
mynum: 123,
mybool: true,
};
const root = ReactTestRenderer.create(
- <PropertiesForm types={types} value={values} />,
- ).root
+ <PropertiesForm types={types} value={values} />
+ ).root;
- let input = root.findByProps({ name: 'mystr' });
- expect(input.props.type).to.equals('text');
- expect(input.props.value).to.equal('abc');
+ let input = root.findByProps({ name: "mystr" });
+ expect(input.props.type).to.equals("text");
+ expect(input.props.value).to.equal("abc");
- input = root.findByProps({ name: 'mynum' });
- expect(input.props.type).to.equals('number');
+ input = root.findByProps({ name: "mynum" });
+ expect(input.props.type).to.equals("number");
expect(input.props.value).to.equal(123);
- input = root.findByProps({ name: 'mybool' });
- expect(input.props.type).to.equals('checkbox');
+ input = root.findByProps({ name: "mybool" });
+ expect(input.props.type).to.equals("checkbox");
expect(input.props.value).to.equal(true);
});
});
- describe('onChange', () => {
+ describe("onChange", () => {
let container;
beforeEach(() => {
- container = document.createElement('div');
+ container = document.createElement("div");
document.body.appendChild(container);
});
@@ -50,53 +50,62 @@ describe("settings/form/PropertiesForm", () => {
container = null;
});
- it('invokes onChange event on text changed', (done) => {
+ it("invokes onChange event on text changed", (done) => {
ReactTestUtils.act(() => {
- ReactDOM.render(<PropertiesForm
- types={{ 'myvalue': 'string' }}
- value={{ 'myvalue': 'abc' }}
- onChange={value => {
- expect(value).to.have.property('myvalue', 'abcd');
- done();
- }}
- />, container);
+ ReactDOM.render(
+ <PropertiesForm
+ types={{ myvalue: "string" }}
+ value={{ myvalue: "abc" }}
+ onChange={(value) => {
+ expect(value).to.have.property("myvalue", "abcd");
+ done();
+ }}
+ />,
+ container
+ );
});
- const input = document.querySelector('input[name=myvalue]');
- input.value = 'abcd'
+ const input = document.querySelector("input[name=myvalue]");
+ input.value = "abcd";
ReactTestUtils.Simulate.change(input);
});
- it('invokes onChange event on number changeed', (done) => {
+ it("invokes onChange event on number changeed", (done) => {
ReactTestUtils.act(() => {
- ReactDOM.render(<PropertiesForm
- types={{ 'myvalue': 'number' }}
- value={{ '': 123 }}
- onChange={value => {
- expect(value).to.have.property('myvalue', 1234);
- done();
- }}
- />, container);
+ ReactDOM.render(
+ <PropertiesForm
+ types={{ myvalue: "number" }}
+ value={{ "": 123 }}
+ onChange={(value) => {
+ expect(value).to.have.property("myvalue", 1234);
+ done();
+ }}
+ />,
+ container
+ );
});
- const input = document.querySelector('input[name=myvalue]');
- input.value = '1234'
+ const input = document.querySelector("input[name=myvalue]");
+ input.value = "1234";
ReactTestUtils.Simulate.change(input);
});
- it('invokes onChange event on checkbox changed', (done) => {
+ it("invokes onChange event on checkbox changed", (done) => {
ReactTestUtils.act(() => {
- ReactDOM.render(<PropertiesForm
- types={{ 'myvalue': 'boolean' }}
- value={{ 'myvalue': false }}
- onChange={value => {
- expect(value).to.have.property('myvalue', true);
- done();
- }}
- />, container);
+ ReactDOM.render(
+ <PropertiesForm
+ types={{ myvalue: "boolean" }}
+ value={{ myvalue: false }}
+ onChange={(value) => {
+ expect(value).to.have.property("myvalue", true);
+ done();
+ }}
+ />,
+ container
+ );
});
- const input = document.querySelector('input[name=myvalue]');
+ const input = document.querySelector("input[name=myvalue]");
input.checked = true;
ReactTestUtils.Simulate.change(input);
});