@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"
38 lines (32 loc) • 1.31 kB
JavaScript
// @flow
import * as React from "react";
import { shallow } from "enzyme";
import Illustration from "../index";
import { SIZE_OPTIONS } from "../consts";
import SPACINGS_AFTER from "../../common/getSpacingToken/consts";
import defaultTokens from "../../defaultTokens";
const size = SIZE_OPTIONS.SMALL;
const name = "Accommodation";
const dataTest = "test";
const URL = "//images.kiwi.com/illustrations/0x90/Accommodation.png";
const URL_RETINA = "//images.kiwi.com/illustrations/0x180/Accommodation.png 2x";
describe(`Illustration of ${name}`, () => {
const component = shallow(
<Illustration size={size} name={name} dataTest={dataTest} spaceAfter={SPACINGS_AFTER.NORMAL} />,
);
it("should have passed props", () => {
expect(component.prop("size")).toBe(size);
expect(component.render().prop("alt")).toBe(name);
expect(component.render().prop("data-test")).toBe(dataTest);
});
it("should render proper image", () => {
expect(component.render().attr("src")).toContain(URL);
expect(component.render().attr("srcset")).toContain(URL_RETINA);
});
it("should have margin-bottom", () => {
expect(component).toHaveStyleRule("margin-bottom", defaultTokens.orbit.spaceSmall);
});
it("should match snapshot", () => {
expect(component).toMatchSnapshot();
});
});