mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-23 02:41:50 +03:00
a703185497
refs TryGhost/Team#1566 - Mocking a labs flag (regardless of enabled/disabled) currently has a side effect of setting any other flag to undefined. - This meant in a test where we set a flag e.g. members-importer where we set multipleProducts, multipleNewsletters is always disabled - This fix preserves the default state of all labs flags that are not mocked so that labs behaves how we expect - Removed usage of GA flags in tests - Removed tests that had GA flags disabled Co-authored-by: Simon Backx <simon@ghost.org>
117 lines
3.6 KiB
JavaScript
117 lines
3.6 KiB
JavaScript
const should = require('should');
|
|
const tiersHelper = require('../../../../core/frontend/helpers/tiers');
|
|
const {mockManager} = require('../../../utils/e2e-framework');
|
|
|
|
describe('{{tiers}} helper', function () {
|
|
it('can return string with tiers', function () {
|
|
const tiers = [
|
|
{name: 'tier 1'},
|
|
{name: 'tier 2'},
|
|
{name: 'tier 3'}
|
|
];
|
|
|
|
const rendered = tiersHelper.call({tiers: tiers}, {hash: {}});
|
|
should.exist(rendered);
|
|
|
|
String(rendered).should.equal('tier 1, tier 2 and tier 3 tiers');
|
|
});
|
|
|
|
it('can use a different separator', function () {
|
|
const tiers = [
|
|
{name: 'tier 1'},
|
|
{name: 'tier 2'},
|
|
{name: 'tier 3'}
|
|
];
|
|
|
|
const rendered = tiersHelper.call({tiers: tiers}, {hash: {separator: '|'}});
|
|
should.exist(rendered);
|
|
|
|
String(rendered).should.equal('tier 1|tier 2 and tier 3 tiers');
|
|
});
|
|
|
|
it('can use a different final separator', function () {
|
|
const tiers = [
|
|
{name: 'tier 1'},
|
|
{name: 'tier 2'},
|
|
{name: 'tier 3'}
|
|
];
|
|
|
|
const rendered = tiersHelper.call({tiers: tiers}, {hash: {lastSeparator: ' as well as '}});
|
|
should.exist(rendered);
|
|
|
|
String(rendered).should.equal('tier 1, tier 2 as well as tier 3 tiers');
|
|
});
|
|
|
|
it('can add a single prefix to multiple tiers', function () {
|
|
const tiers = [
|
|
{name: 'tier 1'},
|
|
{name: 'tier 2'},
|
|
{name: 'tier 3'}
|
|
];
|
|
|
|
const rendered = tiersHelper.call({tiers: tiers}, {hash: {prefix: 'on '}});
|
|
should.exist(rendered);
|
|
|
|
String(rendered).should.equal('on tier 1, tier 2 and tier 3 tiers');
|
|
});
|
|
|
|
it('can add a single suffix to multiple tiers', function () {
|
|
const tiers = [
|
|
{name: 'tier 1'},
|
|
{name: 'tier 2'},
|
|
{name: 'tier 3'}
|
|
];
|
|
|
|
const rendered = tiersHelper.call({tiers: tiers}, {hash: {suffix: ' products'}});
|
|
should.exist(rendered);
|
|
|
|
String(rendered).should.equal('tier 1, tier 2 and tier 3 products');
|
|
});
|
|
|
|
it('can override empty suffix to multiple tiers', function () {
|
|
const tiers = [
|
|
{name: 'tier 1'},
|
|
{name: 'tier 2'},
|
|
{name: 'tier 3'}
|
|
];
|
|
|
|
const rendered = tiersHelper.call({tiers: tiers}, {hash: {suffix: ''}});
|
|
should.exist(rendered);
|
|
|
|
String(rendered).should.equal('tier 1, tier 2 and tier 3');
|
|
});
|
|
|
|
it('can add a prefix and suffix to multiple tiers', function () {
|
|
const tiers = [
|
|
{name: 'tier 1'},
|
|
{name: 'tier 2'},
|
|
{name: 'tier 3'}
|
|
];
|
|
|
|
const rendered = tiersHelper.call({tiers: tiers}, {hash: {prefix: 'on ', suffix: ' products'}});
|
|
should.exist(rendered);
|
|
|
|
String(rendered).should.equal('on tier 1, tier 2 and tier 3 products');
|
|
});
|
|
|
|
it('can add a prefix and suffix with HTML', function () {
|
|
const tiers = [
|
|
{name: 'tier 1'},
|
|
{name: 'tier 2'},
|
|
{name: 'tier 3'}
|
|
];
|
|
|
|
const rendered = tiersHelper.call({tiers: tiers}, {hash: {suffix: ' •', prefix: '… '}});
|
|
should.exist(rendered);
|
|
|
|
String(rendered).should.equal('… tier 1, tier 2 and tier 3 •');
|
|
});
|
|
|
|
it('does not add prefix or suffix if no tiers exist', function () {
|
|
const rendered = tiersHelper.call({}, {hash: {prefix: 'on ', suffix: ' products'}});
|
|
should.exist(rendered);
|
|
|
|
String(rendered).should.equal('');
|
|
});
|
|
});
|