@kiwicom/orbit-components
Version:
<div align="center"> <a href="https://orbit.kiwi" target="_blank"> <img alt="orbit-components" src="https://orbit.kiwi/wp-content/uploads/2018/08/orbit-components.png" srcset="https://orbit.kiwi/wp-content/uploads/2018/08/orbit-components@2x.png 2x"
40 lines (37 loc) • 1.32 kB
JavaScript
// @flow
import * as React from "react";
import { shallow, mount } from "enzyme";
import Text from "../index";
import SPACINGS_AFTER from "../../common/getSpacingToken/consts";
import { SIZE_OPTIONS, TYPE_OPTIONS } from "../consts";
import defaultTokens from "../../defaultTokens";
describe("Text", () => {
const text = "Children text";
const dataTest = "test";
const spaceAfter = SPACINGS_AFTER.NORMAL;
const type = TYPE_OPTIONS.PRIMARY;
const size = SIZE_OPTIONS.SMALL;
const component = shallow(
<Text type={type} size={size} dataTest={dataTest} spaceAfter={spaceAfter}>
{text}
</Text>,
);
it("should have passed props", () => {
expect(component.prop("type")).toBe(type);
expect(component.prop("size")).toBe(size);
expect(component.prop("spaceAfter")).toBe(spaceAfter);
});
it("should contain children", () => {
expect(component.children().text()).toBe(text);
});
it("should have data-test", () => {
expect(component.render().prop("data-test")).toBe(dataTest);
});
it("should have margin-bottom", () => {
const mounted = mount(<Text spaceAfter={spaceAfter}>{text}</Text>);
expect(mounted).toHaveStyleRule("margin-bottom", defaultTokens.orbit.spaceSmall);
});
it("should match snapshot", () => {
expect(component).toMatchSnapshot();
});
});