2020-04-29 18:44:27 +03:00
|
|
|
const should = require('should');
|
2014-10-10 18:54:07 +04:00
|
|
|
|
2020-04-29 18:44:27 +03:00
|
|
|
// Stuff we are testing
|
|
|
|
const helpers = require('../../../core/frontend/helpers');
|
2014-10-10 18:54:07 +04:00
|
|
|
|
|
|
|
describe('{{plural}} helper', function () {
|
|
|
|
it('will show no-value string', function () {
|
2020-04-29 18:44:27 +03:00
|
|
|
const expected = 'No Posts';
|
|
|
|
|
|
|
|
const rendered = helpers.plural.call({}, 0, {
|
|
|
|
hash: {
|
|
|
|
empty: 'No Posts',
|
|
|
|
singular: '% Post',
|
|
|
|
plural: '% Posts'
|
|
|
|
}
|
|
|
|
});
|
2014-10-10 18:54:07 +04:00
|
|
|
|
|
|
|
should.exist(rendered);
|
|
|
|
rendered.string.should.equal(expected);
|
|
|
|
});
|
|
|
|
|
2015-09-22 18:00:20 +03:00
|
|
|
it('will show no-value string with placement', function () {
|
2020-04-29 18:44:27 +03:00
|
|
|
const expected = '0 Posts';
|
|
|
|
|
|
|
|
const rendered = helpers.plural.call({}, 0, {
|
|
|
|
hash: {
|
|
|
|
empty: '% Posts',
|
|
|
|
singular: '% Post',
|
|
|
|
plural: '% Posts'
|
|
|
|
}
|
|
|
|
});
|
2015-09-22 18:00:20 +03:00
|
|
|
|
|
|
|
should.exist(rendered);
|
|
|
|
rendered.string.should.equal(expected);
|
|
|
|
});
|
|
|
|
|
2014-10-10 18:54:07 +04:00
|
|
|
it('will show singular string', function () {
|
2020-04-29 18:44:27 +03:00
|
|
|
const expected = '1 Post';
|
|
|
|
|
|
|
|
const rendered = helpers.plural.call({}, 1, {
|
|
|
|
hash: {
|
|
|
|
empty: 'No Posts',
|
|
|
|
singular: '% Post',
|
|
|
|
plural: '% Posts'
|
|
|
|
}
|
|
|
|
});
|
2014-10-10 18:54:07 +04:00
|
|
|
|
|
|
|
should.exist(rendered);
|
|
|
|
rendered.string.should.equal(expected);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('will show plural string', function () {
|
2020-04-29 18:44:27 +03:00
|
|
|
const expected = '2 Posts';
|
|
|
|
|
|
|
|
const rendered = helpers.plural.call({}, 2, {
|
|
|
|
hash: {
|
|
|
|
empty: 'No Posts',
|
|
|
|
singular: '% Post',
|
|
|
|
plural: '% Posts'
|
|
|
|
}
|
|
|
|
});
|
2014-10-10 18:54:07 +04:00
|
|
|
|
|
|
|
should.exist(rendered);
|
|
|
|
rendered.string.should.equal(expected);
|
|
|
|
});
|
|
|
|
});
|