DocSpace-buildtools/packages/components/file-input/file-input.test.js

45 lines
1.1 KiB
JavaScript
Raw Normal View History

import React from "react";
import { mount, shallow } from "enzyme";
import FileInput from ".";
2020-07-17 12:28:58 +00:00
describe("<FileInput />", () => {
it("renders without error", () => {
const wrapper = mount(<FileInput onInput={jest.fn()} />);
2020-07-17 12:28:58 +00:00
expect(wrapper).toExist();
});
it("not re-render test", () => {
2020-07-17 12:28:58 +00:00
const onInput = jest.fn();
const wrapper = shallow(<FileInput onInput={onInput} />).instance();
const shouldUpdate = wrapper.shouldComponentUpdate(
wrapper.props,
wrapper.state
);
2020-07-17 12:28:58 +00:00
expect(shouldUpdate).toBe(false);
});
it("accepts id", () => {
const wrapper = mount(<FileInput onInput={jest.fn()} id="testId" />);
2020-07-17 12:28:58 +00:00
expect(wrapper.prop("id")).toEqual("testId");
2020-07-17 12:28:58 +00:00
});
it("accepts className", () => {
const wrapper = mount(<FileInput onInput={jest.fn()} className="test" />);
2020-07-17 12:28:58 +00:00
expect(wrapper.prop("className")).toEqual("test");
2020-07-17 12:28:58 +00:00
});
it("accepts style", () => {
2020-07-17 12:28:58 +00:00
const wrapper = mount(
<FileInput onInput={jest.fn()} style={{ color: "red" }} />
2020-07-17 12:28:58 +00:00
);
expect(wrapper.getDOMNode().style).toHaveProperty("color", "red");
2020-07-17 12:28:58 +00:00
});
});