2020-10-16 13:16:01 +00:00
|
|
|
import React from "react";
|
|
|
|
import { mount } from "enzyme";
|
|
|
|
import Badge from ".";
|
2019-09-06 09:29:18 +00:00
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
describe("<Badge />", () => {
|
|
|
|
it("renders without error", () => {
|
|
|
|
const wrapper = mount(<Badge />);
|
2019-09-06 09:29:18 +00:00
|
|
|
|
|
|
|
expect(wrapper).toExist();
|
|
|
|
});
|
2019-11-26 09:09:39 +00:00
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
it("displays label", () => {
|
|
|
|
const wrapper = mount(<Badge label="10" />);
|
2019-11-26 09:09:39 +00:00
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
expect(wrapper.prop("label")).toBe("10");
|
2019-11-26 09:09:39 +00:00
|
|
|
});
|
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
it("call onClick()", () => {
|
2019-11-26 09:09:39 +00:00
|
|
|
const onClick = jest.fn();
|
2020-10-16 13:16:01 +00:00
|
|
|
const wrapper = mount(<Badge onClick={onClick} />);
|
2019-11-26 09:09:39 +00:00
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
wrapper.simulate("click");
|
2019-11-26 09:09:39 +00:00
|
|
|
|
|
|
|
expect(onClick).toBeCalled();
|
|
|
|
});
|
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
it("call onClick() without wrapper", () => {
|
|
|
|
const wrapper = mount(<Badge />);
|
|
|
|
|
|
|
|
wrapper.simulate("click");
|
2019-11-26 09:09:39 +00:00
|
|
|
|
|
|
|
expect(wrapper).toExist();
|
|
|
|
});
|
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
it("accepts id", () => {
|
|
|
|
const wrapper = mount(<Badge id="testId" />);
|
2019-11-26 09:09:39 +00:00
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
expect(wrapper.prop("id")).toEqual("testId");
|
2019-11-26 09:09:39 +00:00
|
|
|
});
|
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
it("accepts className", () => {
|
|
|
|
const wrapper = mount(<Badge className="test" />);
|
2019-11-26 09:09:39 +00:00
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
expect(wrapper.prop("className")).toEqual("test");
|
2019-11-26 09:09:39 +00:00
|
|
|
});
|
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
it("accepts style", () => {
|
|
|
|
const wrapper = mount(<Badge style={{ color: "red" }} />);
|
2019-11-26 09:09:39 +00:00
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
expect(wrapper.getDOMNode().style).toHaveProperty("color", "red");
|
2019-11-26 09:09:39 +00:00
|
|
|
});
|
2019-09-06 09:29:18 +00:00
|
|
|
});
|