debian-mirror-gitlab/spec/frontend/lib/utils/grammar_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
1.1 KiB
JavaScript
Raw Normal View History

2019-03-02 22:35:43 +05:30
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-07-28 23:09:34 +05:30
const items = ['Lorem & Ipsum'];
2019-03-02 22:35:43 +05:30
expect(grammar.toNounSeriesText(items)).toBe(items[0]);
});
it('with 2 items returns item1 and item2', () => {
2020-07-28 23:09:34 +05:30
const items = ['Dolar', 'Sit & Amit'];
2019-03-02 22:35:43 +05:30
expect(grammar.toNounSeriesText(items)).toBe(`${items[0]} and ${items[1]}`);
});
it('with 3 items returns comma separated series', () => {
2020-07-28 23:09:34 +05:30
const items = ['Lorem', 'Ipsum', 'Sit & Amit'];
const expected = 'Lorem, Ipsum, and Sit & Amit';
2019-03-02 22:35:43 +05:30
expect(grammar.toNounSeriesText(items)).toBe(expected);
});
it('with 6 items returns comma separated series', () => {
2020-07-28 23:09:34 +05:30
const items = ['Lorem', 'ipsum', 'dolar', 'sit', 'amit', 'consectetur & adipiscing'];
const expected = 'Lorem, ipsum, dolar, sit, amit, and consectetur & adipiscing';
2019-03-02 22:35:43 +05:30
expect(grammar.toNounSeriesText(items)).toBe(expected);
});
});
});