@financial-times/n-conversion-forms
Version:
Containing jsx components and styles for forms included on Accounts and Acquisition apps (next-signup, next-profile, next-retention, etc).
96 lines (95 loc) • 3.7 kB
JSX
;
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(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
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);
});
});