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.
56 lines (53 loc) • 2.65 kB
JavaScript
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
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 { TextInput, TEXT_INPUT_TYPES } from ".";
import { BREAKPOINTS } from "../../constants/breakpoints";
import createSnapshot from "../../test/create-snapshot";
describe("<TextInput /> snapshot tests", function () {
var textInputProps = {
onChange: function onChange() {}
};
it("renders <TextInput /> component correctly with default props", function () {
var snapshot = createSnapshot(React.createElement(TextInput, textInputProps));
expect(snapshot).toMatchSnapshot();
});
it("renders <TextInput /> component correctly with different type: password", function () {
var snapshot = createSnapshot(React.createElement(TextInput, _extends({
type: TEXT_INPUT_TYPES.PASSWORD
}, textInputProps)));
expect(snapshot).toMatchSnapshot();
});
it("renders <TextInput /> component correctly with theme", function () {
var theme = {
input: {
background: "yellow"
}
};
var snapshot = createSnapshot(React.createElement(TextInput, textInputProps), theme);
expect(snapshot).toMatchSnapshot();
});
it("renders <TextInput /> component correctly with theme and media queries", function () {
var _input;
var theme = {
input: (_input = {}, _defineProperty(_input, BREAKPOINTS.onS, {
background: "blue"
}), _defineProperty(_input, BREAKPOINTS.onM, {
background: "orange"
}), _defineProperty(_input, BREAKPOINTS.onL, {
background: "magenta"
}), _input)
};
var snapshot = createSnapshot(React.createElement(TextInput, textInputProps), theme);
expect(snapshot).toMatchSnapshot();
});
it("verifies the correct and supported input text types", function () {
expect(TEXT_INPUT_TYPES.PASSWORD).toEqual("password");
expect(TEXT_INPUT_TYPES.EMAIL).toEqual("email");
expect(TEXT_INPUT_TYPES.TELEPHONE).toEqual("tel");
expect(TEXT_INPUT_TYPES.SEARCH).toEqual("search");
expect(TEXT_INPUT_TYPES.TEXT).toEqual("text");
expect(TEXT_INPUT_TYPES.NUMBER).toEqual("number");
expect(Object.keys(TEXT_INPUT_TYPES).length).toEqual(6);
});
});