2019-01-14 02:42:53 -05:00
|
|
|
import * as grammar from '~/lib/utils/grammar';
|
|
|
|
|
|
|
|
describe('utils/grammar', () => {
|
|
|
|
describe('toNounSeriesText', () => {
|
|
|
|
it('with empty items returns empty string', () => {
|
|
|
|
expect(grammar.toNounSeriesText([])).toBe('');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('with single item returns item', () => {
|
2020-06-30 17:09:47 -04:00
|
|
|
const items = ['Lorem & Ipsum'];
|
2019-01-14 02:42:53 -05:00
|
|
|
|
|
|
|
expect(grammar.toNounSeriesText(items)).toBe(items[0]);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('with 2 items returns item1 and item2', () => {
|
2020-06-30 17:09:47 -04:00
|
|
|
const items = ['Dolar', 'Sit & Amit'];
|
2019-01-14 02:42:53 -05:00
|
|
|
|
|
|
|
expect(grammar.toNounSeriesText(items)).toBe(`${items[0]} and ${items[1]}`);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('with 3 items returns comma separated series', () => {
|
2020-06-30 17:09:47 -04:00
|
|
|
const items = ['Lorem', 'Ipsum', 'Sit & Amit'];
|
|
|
|
const expected = 'Lorem, Ipsum, and Sit & Amit';
|
2019-01-14 02:42:53 -05:00
|
|
|
|
|
|
|
expect(grammar.toNounSeriesText(items)).toBe(expected);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('with 6 items returns comma separated series', () => {
|
2020-06-30 17:09:47 -04:00
|
|
|
const items = ['Lorem', 'ipsum', 'dolar', 'sit', 'amit', 'consectetur & adipiscing'];
|
|
|
|
const expected = 'Lorem, ipsum, dolar, sit, amit, and consectetur & adipiscing';
|
2019-01-14 02:42:53 -05:00
|
|
|
|
|
|
|
expect(grammar.toNounSeriesText(items)).toBe(expected);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|