2020-10-16 13:16:01 +00:00
|
|
|
import React from "react";
|
|
|
|
import { mount } from "enzyme";
|
|
|
|
import RadioButtonGroup from ".";
|
2019-09-08 15:11:53 +00:00
|
|
|
|
2019-12-03 12:45:13 +00:00
|
|
|
const baseProps = {
|
2020-10-16 13:16:01 +00:00
|
|
|
name: "fruits",
|
|
|
|
selected: "banana",
|
2019-12-03 12:45:13 +00:00
|
|
|
options: [
|
2020-10-16 13:16:01 +00:00
|
|
|
{ value: "apple", label: "Sweet apple" },
|
|
|
|
{ value: "banana", label: "Banana" },
|
|
|
|
{ value: "Mandarin" },
|
|
|
|
],
|
|
|
|
};
|
|
|
|
|
|
|
|
describe("<RadioButtonGroup />", () => {
|
|
|
|
it("renders without error", () => {
|
|
|
|
const wrapper = mount(<RadioButtonGroup {...baseProps} />);
|
2019-09-08 15:11:53 +00:00
|
|
|
|
|
|
|
expect(wrapper).toExist();
|
|
|
|
});
|
2019-12-03 12:45:13 +00:00
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
it("accepts id", () => {
|
|
|
|
const wrapper = mount(<RadioButtonGroup {...baseProps} id="testId" />);
|
2019-12-03 12:45:13 +00:00
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
expect(wrapper.prop("id")).toEqual("testId");
|
2019-12-03 12:45:13 +00:00
|
|
|
});
|
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
it("accepts className", () => {
|
|
|
|
const wrapper = mount(<RadioButtonGroup {...baseProps} className="test" />);
|
2019-12-03 12:45:13 +00:00
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
expect(wrapper.prop("className")).toEqual("test");
|
2019-12-03 12:45:13 +00:00
|
|
|
});
|
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
it("accepts style", () => {
|
2019-12-03 12:45:13 +00:00
|
|
|
const wrapper = mount(
|
2020-10-16 13:16:01 +00:00
|
|
|
<RadioButtonGroup {...baseProps} style={{ color: "red" }} />
|
2019-12-03 12:45:13 +00:00
|
|
|
);
|
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
expect(wrapper.getDOMNode().style).toHaveProperty("color", "red");
|
2019-12-03 12:45:13 +00:00
|
|
|
});
|
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
it("accepts isDisabled prop", () => {
|
|
|
|
const wrapper = mount(<RadioButtonGroup {...baseProps} isDisabled />);
|
2019-12-03 12:45:13 +00:00
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
expect(wrapper.prop("isDisabled")).toEqual(true);
|
2019-12-03 12:45:13 +00:00
|
|
|
});
|
2019-09-08 15:11:53 +00:00
|
|
|
});
|