UNPKG

@financial-times/n-conversion-forms

Version:

Containing jsx components and styles for forms included on Accounts and Acqusition apps (next-signup, next-profile, next-retention, etc).

96 lines (95 loc) 3.88 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); var _index = require("./index"); var _expectToRenderCorrectly = require("../test-jest/helpers/expect-to-render-correctly"); function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } expect.extend(_expectToRenderCorrectly.expectToRenderCorrectly); var ACTION_MOCK = { text: 'Listen on Spotify', link: 'https://open.spotify.com/album/2EpuND32cO7CX0gXZl2NB6' }; describe('Message', function () { it('render a message', function () { var props = { message: 'My message in a bottle' }; expect(_index.Message).toRenderCorrectly(props); }); it('can render a title', function () { var props = { title: 'Reggatta de Blanc', message: 'My message in a bottle' }; expect(_index.Message).toRenderCorrectly(props); }); it('can render additional information', function () { var props = { title: 'Reggatta de Blanc', message: 'My message in a bottle', additional: ['Sting', 'Steward Copeland', 'Andy Summers'] }; expect(_index.Message).toRenderCorrectly(props); }); it('can render some actions as primary', function () { var props = { title: 'Reggatta de Blanc', message: 'My message in a bottle', actions: [ACTION_MOCK] }; expect(_index.Message).toRenderCorrectly(props); }); it('can render some actions as secondary', function () { var props = { title: 'Reggatta de Blanc', message: 'My message in a bottle', actions: [_objectSpread(_objectSpread({}, ACTION_MOCK), {}, { isSecondary: true })] }; expect(_index.Message).toRenderCorrectly(props); }); it('can render a message as a Notice', function () { var props = { message: 'My message in a bottle', isNotice: true }; expect(_index.Message).toRenderCorrectly(props); }); it('can render a message as an Error', function () { var props = { message: 'My message in a bottle', isError: true }; expect(_index.Message).toRenderCorrectly(props); }); it('can render a message as a Success', function () { var props = { message: 'My message in a bottle', isSuccess: true }; expect(_index.Message).toRenderCorrectly(props); }); it('can render a message as an Inform', function () { var props = { message: 'My message in a bottle', isInform: true }; expect(_index.Message).toRenderCorrectly(props); }); it('can add a data attribute name', function () { var props = { message: 'My message in a bottle', name: 'The Police best album ever' }; expect(_index.Message).toRenderCorrectly(props); }); it('can set the action link target of call to action buttons', function () { var props = { target: '_top', actions: [ACTION_MOCK] }; expect(_index.Message).toRenderCorrectly(props); }); });