2020-10-16 13:16:01 +00:00
|
|
|
import React from "react";
|
|
|
|
import { mount } from "enzyme";
|
|
|
|
import Label from ".";
|
2019-11-28 13:13:16 +00:00
|
|
|
|
|
|
|
const baseProps = {
|
|
|
|
text: "First name:",
|
|
|
|
title: "first name",
|
|
|
|
htmlFor: "firstNameField",
|
2020-10-16 13:16:01 +00:00
|
|
|
display: "block",
|
2019-11-28 13:13:16 +00:00
|
|
|
};
|
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
describe("<Label />", () => {
|
|
|
|
it("renders without error", () => {
|
|
|
|
const wrapper = mount(<Label {...baseProps} />);
|
2019-11-28 13:13:16 +00:00
|
|
|
|
|
|
|
expect(wrapper).toExist();
|
|
|
|
});
|
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
it("display error", () => {
|
|
|
|
const wrapper = mount(<Label {...baseProps} error />);
|
2019-11-28 13:13:16 +00:00
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
expect(wrapper.prop("error")).toBe(true);
|
2019-11-28 13:13:16 +00:00
|
|
|
});
|
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
it("display required", () => {
|
|
|
|
const wrapper = mount(<Label {...baseProps} isRequired />);
|
2019-11-28 13:13:16 +00:00
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
expect(wrapper.prop("isRequired")).toBe(true);
|
2019-11-28 13:13:16 +00:00
|
|
|
});
|
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
it("accepts id", () => {
|
|
|
|
const wrapper = mount(<Label {...baseProps} id="testId" />);
|
2019-11-28 13:13:16 +00:00
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
expect(wrapper.prop("id")).toEqual("testId");
|
2019-11-28 13:13:16 +00:00
|
|
|
});
|
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
it("accepts className", () => {
|
|
|
|
const wrapper = mount(<Label {...baseProps} className="test" />);
|
2019-11-28 13:13:16 +00:00
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
expect(wrapper.prop("className")).toEqual("test");
|
2019-11-28 13:13:16 +00:00
|
|
|
});
|
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
it("accepts style", () => {
|
|
|
|
const wrapper = mount(<Label {...baseProps} style={{ color: "red" }} />);
|
2019-11-28 13:13:16 +00:00
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
expect(wrapper.getDOMNode().style).toHaveProperty("color", "red");
|
2019-11-28 13:13:16 +00:00
|
|
|
});
|
|
|
|
});
|