UNPKG

@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"

51 lines (40 loc) 1.72 kB
// @flow import * as React from "react"; import { mount } from "enzyme"; import defaultTokens from "../../defaultTokens"; import { NAME_OPTIONS, SIZE_OPTIONS, baseURL } from "../consts"; import ServiceLogo from "../index"; const name = NAME_OPTIONS.AIRHELP; const size = SIZE_OPTIONS.LARGE; const grayScale = true; const SIZE = defaultTokens.orbit.heightServiceLogoLarge; describe(`ServiceLogo: ${name}`, () => { const component = mount(<ServiceLogo name={name} size={size} />).find("img"); it("should have props", () => { const IMAGE_PATH = `${baseURL}/logos/0x${parseInt(SIZE, 10)}/${name}.png`; const IMAGE_PATH_RETINA = `${baseURL}/logos/0x${parseInt(SIZE, 10) * 2}/${name}.png`; expect(component.prop("src")).toBe(IMAGE_PATH); expect(component.prop("srcSet")).toBe(`${IMAGE_PATH_RETINA} 2x`); expect(component.prop("alt")).toBe(name); }); it("should match snapshot", () => { expect(component).toMatchSnapshot(); }); }); describe(`ServiceLogo: ${name}`, () => { const dataTest = "test"; const component = mount( <ServiceLogo name={name} size={size} grayScale={grayScale} dataTest={dataTest} />, ).find("img"); const IMAGE_PATH = `${baseURL}/logos-grayscale/0x${parseInt(SIZE, 10)}/${name}.png`; const IMAGE_PATH_RETINA = `${baseURL}/logos-grayscale/0x${parseInt(SIZE, 10) * 2}/${name}.png`; it("should have props", () => { expect(component.prop("src")).toBe(IMAGE_PATH); expect(component.prop("srcSet")).toBe(`${IMAGE_PATH_RETINA} 2x`); expect(component.prop("alt")).toBe(name); expect(component.render().prop("data-test")).toBe(dataTest); }); it("should match snapshot", () => { expect(component).toMatchSnapshot(); }); });