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.

58 lines (56 loc) 2.3 kB
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } import React from 'react'; import { Block } from '.'; import createSnapshot from '../../test/create-snapshot'; import render from '../../test/render'; describe('<Block />', function () { it('correctly implements ref prop', function () { var mockRef = React.createRef(); render(React.createElement(Block, { ref: mockRef })); expect(mockRef.current).not.toBe(null); }); it('correctly implements innerRef prop', function () { var mockRef = React.createRef(); render(React.createElement(Block, { innerRef: mockRef })); expect(mockRef.current).not.toBe(null); }); it('renders <Block /> component correctly with default props', function () { var snapshot = createSnapshot(React.createElement(Block, null, "Children")); expect(snapshot).toMatchSnapshot(); }); it("renders <Block /> component correctly with a string given as 'as' prop", function () { var snapshot = createSnapshot(React.createElement(Block, { as: "span" }, "Children")); expect(snapshot).toMatchSnapshot(); }); it('renders <Block /> component correctly with extended styles', function () { var snapshot = createSnapshot(React.createElement(Block, { extend: { color: 'blue' } }, "Children")); expect(snapshot).toMatchSnapshot(); }); it("renders <Block /> component correctly with a React element given as 'as' prop", function () { var CustomElement = function CustomElement(props) { return React.createElement("h1", _extends({ "data-custom": "true" }, props)); }; var snapshot = createSnapshot(React.createElement(Block, { as: CustomElement }, "Children")); expect(snapshot).toMatchSnapshot(); }); it('renders <Block /> component correctly with added custom className', function () { var snapshot = createSnapshot(React.createElement(Block, { className: "test-class" }, "Children")); expect(snapshot).toMatchSnapshot(); }); });