@financial-times/n-conversion-forms 20.6.0 → 22.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -161,6 +161,16 @@ export function PaymentTerm ({
|
|
|
161
161
|
);
|
|
162
162
|
};
|
|
163
163
|
|
|
164
|
+
const getDisplayName = () => {
|
|
165
|
+
let displayName = '';
|
|
166
|
+
if (showTrialCopyInTitle) {
|
|
167
|
+
const termName = option.displayName ? option.displayName : 'Premium Digital';
|
|
168
|
+
displayName = `Trial: ${termName} - `;
|
|
169
|
+
}
|
|
170
|
+
const termPeriod = nameMap[option.name] ? title : option.title;
|
|
171
|
+
return `${displayName}${termPeriod} `;
|
|
172
|
+
};
|
|
173
|
+
|
|
164
174
|
return (
|
|
165
175
|
<div key={option.value} className={className}>
|
|
166
176
|
<input {...props} />
|
|
@@ -176,8 +186,7 @@ export function PaymentTerm ({
|
|
|
176
186
|
{ 'ncf__payment-term__title--large-price': largePrice },
|
|
177
187
|
])}
|
|
178
188
|
>
|
|
179
|
-
{
|
|
180
|
-
{nameMap[option.name] ? title : option.title}{' '}
|
|
189
|
+
{getDisplayName()}
|
|
181
190
|
{option.subTitle && (
|
|
182
191
|
<span className="ncf__regular ncf__payment-term__sub-title">
|
|
183
192
|
{option.subTitle}
|
|
@@ -153,6 +153,48 @@ describe('PaymentTerm', () => {
|
|
|
153
153
|
});
|
|
154
154
|
});
|
|
155
155
|
|
|
156
|
+
describe('getDisplayName', () => {
|
|
157
|
+
const baseOptions = {
|
|
158
|
+
name: 'monthly',
|
|
159
|
+
value: 'monthly',
|
|
160
|
+
price: '£20.00',
|
|
161
|
+
monthlyPrice: '£1.67',
|
|
162
|
+
};
|
|
163
|
+
describe('non-trial terms', () => {
|
|
164
|
+
const options = [{
|
|
165
|
+
...baseOptions,
|
|
166
|
+
isTrial: false,
|
|
167
|
+
}];
|
|
168
|
+
it('renders with time period only if trial.option == false', () => {
|
|
169
|
+
const wrapper = shallow(<PaymentTerm options={options} />);
|
|
170
|
+
expect(wrapper.find('.ncf__payment-term__label').text()).toMatch(/^Monthly .*$/);
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
describe('getDisplayName', () => {
|
|
174
|
+
const trialOptions = {
|
|
175
|
+
...baseOptions,
|
|
176
|
+
isTrial: true,
|
|
177
|
+
};
|
|
178
|
+
it('defaults to `Premium digital`', () => {
|
|
179
|
+
const options = [trialOptions];
|
|
180
|
+
const wrapper = shallow(<PaymentTerm options={options} />);
|
|
181
|
+
expect(wrapper.find('.ncf__payment-term__label').text()).toMatch(
|
|
182
|
+
/^Trial: Premium Digital - Monthly .*$/
|
|
183
|
+
);
|
|
184
|
+
});
|
|
185
|
+
it('renders using displayName if available', () => {
|
|
186
|
+
const options = [{
|
|
187
|
+
...trialOptions,
|
|
188
|
+
displayName: 'someDisplayName',
|
|
189
|
+
}];
|
|
190
|
+
const wrapper = shallow(<PaymentTerm options={options} />);
|
|
191
|
+
expect(wrapper.find('.ncf__payment-term__label').text()).toMatch(
|
|
192
|
+
/^Trial: someDisplayName - Monthly .*/
|
|
193
|
+
);
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
|
|
156
198
|
describe('[data-base-amount]', () => {
|
|
157
199
|
it('renders option.amount as data-base-amount if isTrial is false', () => {
|
|
158
200
|
const options = [
|
package/dist/payment-term.js
CHANGED
|
@@ -146,6 +146,18 @@ function PaymentTerm(_ref) {
|
|
|
146
146
|
}, option.chargeOnText)));
|
|
147
147
|
};
|
|
148
148
|
|
|
149
|
+
var getDisplayName = function getDisplayName() {
|
|
150
|
+
var displayName = '';
|
|
151
|
+
|
|
152
|
+
if (showTrialCopyInTitle) {
|
|
153
|
+
var termName = option.displayName ? option.displayName : 'Premium Digital';
|
|
154
|
+
displayName = "Trial: ".concat(termName, " - ");
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
var termPeriod = nameMap[option.name] ? title : option.title;
|
|
158
|
+
return "".concat(displayName).concat(termPeriod, " ");
|
|
159
|
+
};
|
|
160
|
+
|
|
149
161
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
150
162
|
key: option.value,
|
|
151
163
|
className: className
|
|
@@ -156,7 +168,7 @@ function PaymentTerm(_ref) {
|
|
|
156
168
|
className: (0, _classnames["default"])(['ncf__payment-term__title', {
|
|
157
169
|
'ncf__payment-term__title--large-price': largePrice
|
|
158
170
|
}])
|
|
159
|
-
},
|
|
171
|
+
}, getDisplayName(), option.subTitle && /*#__PURE__*/_react["default"].createElement("span", {
|
|
160
172
|
className: "ncf__regular ncf__payment-term__sub-title"
|
|
161
173
|
}, option.subTitle)), createDescription()));
|
|
162
174
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@financial-times/n-conversion-forms",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "22.0.0",
|
|
4
4
|
"description": "Containing jsx components and styles for forms included on Accounts and Acqusition apps (next-signup, next-profile, next-retention, etc).",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|