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.

50 lines (48 loc) 2.05 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 { Inline } from '.'; import createSnapshot from '../../test/create-snapshot'; import render from '../../test/render'; describe('<Inline />', function () { it('renders <Inline /> correctly with default props', function () { var snapshot = createSnapshot(React.createElement(Inline, null, "Children")); expect(snapshot).toMatchSnapshot(); }); it("renders <Inline /> component correctly with a string given as 'as' prop", function () { var snapshot = createSnapshot(React.createElement(Inline, { as: "span" }, "Children")); expect(snapshot).toMatchSnapshot(); }); it("renders <Inline /> 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(Inline, { as: CustomElement }, "Children")); expect(snapshot).toMatchSnapshot(); }); it('renders <Box /> component correctly with added custom className', function () { var snapshot = createSnapshot(React.createElement(Inline, { className: "test-class" }, "Children")); expect(snapshot).toMatchSnapshot(); }); it('correctly implements ref prop', function () { var mockRef = React.createRef(); render(React.createElement(Inline, { ref: mockRef }, "Hi")); expect(mockRef.current).not.toBe(null); }); it('correctly implements innerRef prop', function () { var mockRef = React.createRef(); render(React.createElement(Inline, { ref: mockRef }, "Hi")); expect(mockRef.current).not.toBe(null); }); });