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
|
2021-10-06 12:52:46 +03:00
|
|
|
const plural = require('../../../../core/frontend/helpers/plural');
|
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';
|
|
|
|
|
2021-10-04 18:30:54 +03:00
|
|
|
const rendered = plural.call({}, 0, {
|
2020-04-29 18:44:27 +03:00
|
|
|
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';
|
|
|
|
|
2021-10-04 18:30:54 +03:00
|
|
|
const rendered = plural.call({}, 0, {
|
2020-04-29 18:44:27 +03:00
|
|
|
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';
|
|
|
|
|
2021-10-04 18:30:54 +03:00
|
|
|
const rendered = plural.call({}, 1, {
|
2020-04-29 18:44:27 +03:00
|
|
|
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';
|
|
|
|
|
2021-10-04 18:30:54 +03:00
|
|
|
const rendered = plural.call({}, 2, {
|
2020-04-29 18:44:27 +03:00
|
|
|
hash: {
|
|
|
|
empty: 'No Posts',
|
|
|
|
singular: '% Post',
|
|
|
|
plural: '% Posts'
|
|
|
|
}
|
|
|
|
});
|
2014-10-10 18:54:07 +04:00
|
|
|
|
|
|
|
should.exist(rendered);
|
|
|
|
rendered.string.should.equal(expected);
|
|
|
|
});
|
|
|
|
});
|