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