UNPKG

vcc-ui

Version:

VCC UI is a collection of React UI Components that can be used for developing front-end applications at Volvo Car Corporation.

89 lines (85 loc) 3.16 kB
import React from "react"; import { Logo, LOGO_TYPES } from "."; import { getImagesSrc } from "./helpers"; import createSnapshot from "../../test/create-snapshot"; describe("<Logo /> snapshot tests", function () { it("renders correctly with default props", function () { var snapshot = createSnapshot(React.createElement(Logo, null)); expect(snapshot).toMatchSnapshot(); }); it("renders correctly with type=LOGO_TYPES.WORDMARK ", function () { var snapshot = createSnapshot(React.createElement(Logo, { type: LOGO_TYPES.WORDMARK })); expect(snapshot).toMatchSnapshot(); }); it("renders <Logo /> correctly with theme", function () { var theme = { logoImages: { square: "vcc-ui/images/polestar-logo.png", square2x: "vcc-ui/images/polestar-logo-2x.png", wordmark: "vcc-ui/images/polestar-wordmark-white.png", wordmark2x: "vcc-ui/images/polestar-wordmark-white-2x.png" }, logo: { color: "#ffffff" } }; var snapshot = createSnapshot(React.createElement(Logo, { type: LOGO_TYPES.WORDMARK, altText: "Polestar" }), theme); expect(snapshot).toMatchSnapshot(); }); }); describe("<Logo /> helper tests", function () { it("returns theme images srcSet", function () { var defaultImages = { square: "vcc-ui/images/volvo-logo.png", square2x: "vcc-ui/images/volvo-logo-2x.png", wordmark: "vcc-ui/images/volvo-wordmark-white.png", wordmark2x: "vcc-ui/images/volvo-wordmark-white-2x.png" }; var type = LOGO_TYPES.SQUARE; var pathPrefix = "/myfolder/"; var theme = {}; var _getImagesSrc = getImagesSrc({ type: type, theme: theme, defaultImages: defaultImages, pathPrefix: pathPrefix }), src = _getImagesSrc.src, srcSet = _getImagesSrc.srcSet; expect(src).toEqual("".concat(pathPrefix).concat(defaultImages.square)); expect(srcSet).toEqual("".concat(src, ", ").concat(pathPrefix).concat(defaultImages.square2x, " 2x")); }); it("returns theme images srcSet", function () { var defaultImages = { square: "vcc-ui/images/volvo-logo.png", square2x: "vcc-ui/images/volvo-logo-2x.png", wordmark: "vcc-ui/images/volvo-wordmark-white.png", wordmark2x: "vcc-ui/images/volvo-wordmark-white-2x.png" }; var pathPrefix = "/myfolder/"; var theme = { logoImages: { square: "https://polsestar.com/images/polestar-logo.png", square2x: "https://polsestar.com/images/polestar-logo-2x.png", wordmark: "https://polsestar.com/images/polestar-wordmark-white.png", wordmark2x: "https://polsestar.com/images/polestar-wordmark-white-2x.png" } }; var type = LOGO_TYPES.WORDMARK; var _getImagesSrc2 = getImagesSrc({ type: type, theme: theme, defaultImages: defaultImages, pathPrefix: pathPrefix }), src = _getImagesSrc2.src, srcSet = _getImagesSrc2.srcSet; expect(src).toEqual("".concat(theme.logoImages.wordmark)); expect(srcSet).toEqual("".concat(src, ", ").concat(theme.logoImages.wordmark2x, " 2x")); }); });