2019-10-07 11:39:21 +00:00
|
|
|
import React from "react";
|
2019-12-03 14:17:53 +00:00
|
|
|
import { mount } from "enzyme";
|
2019-10-07 11:39:21 +00:00
|
|
|
import Tooltip from ".";
|
2019-12-04 09:36:13 +00:00
|
|
|
import Text from "../text";
|
2019-10-07 11:39:21 +00:00
|
|
|
|
|
|
|
describe("<Tooltip />", () => {
|
|
|
|
it("renders without error", () => {
|
2020-10-16 13:16:01 +00:00
|
|
|
const wrapper = mount(<Tooltip>{<Text>You tooltip text</Text>}</Tooltip>);
|
2019-10-07 11:39:21 +00:00
|
|
|
|
|
|
|
expect(wrapper).toExist();
|
|
|
|
});
|
2019-10-21 05:59:47 +00:00
|
|
|
|
|
|
|
it("Tooltip componentDidUpdate() lifecycle test", () => {
|
|
|
|
const wrapper = mount(
|
2019-12-04 09:36:13 +00:00
|
|
|
<Tooltip>{<Text>You tooltip text</Text>}</Tooltip>
|
2019-10-21 05:59:47 +00:00
|
|
|
).instance();
|
|
|
|
wrapper.componentDidUpdate(wrapper.props, wrapper.state);
|
|
|
|
expect(wrapper.props).toBe(wrapper.props);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Tooltip componentDidUpdate() lifecycle test", () => {
|
|
|
|
const wrapper = mount(
|
2019-12-04 09:36:13 +00:00
|
|
|
<Tooltip>{<Text>You tooltip text</Text>}</Tooltip>
|
2019-10-21 05:59:47 +00:00
|
|
|
).instance();
|
|
|
|
wrapper.componentDidUpdate(wrapper.props, wrapper.state);
|
|
|
|
expect(wrapper.props).toBe(wrapper.props);
|
|
|
|
});
|
2019-12-03 13:55:43 +00:00
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
it("accepts className", () => {
|
|
|
|
const wrapper = mount(<Tooltip className="test" />);
|
2019-12-03 13:55:43 +00:00
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
expect(wrapper.prop("className")).toEqual("test");
|
2019-12-03 13:55:43 +00:00
|
|
|
});
|
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
it("accepts style", () => {
|
|
|
|
const wrapper = mount(<Tooltip style={{ color: "red" }} />);
|
2019-12-03 13:55:43 +00:00
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
expect(wrapper.getDOMNode().style).toHaveProperty("color", "red");
|
2019-12-03 13:55:43 +00:00
|
|
|
});
|
2019-10-07 11:39:21 +00:00
|
|
|
});
|