summaryrefslogtreecommitdiff
path: root/spec/javascripts/lib
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2019-02-05 10:33:47 +0000
committerPhil Hughes <me@iamphill.com>2019-02-05 10:33:47 +0000
commit97041bb6c480e94593b1b7ee3102149ad30804dc (patch)
tree5a076061868f692f26cfb59c01ec6485997f8395 /spec/javascripts/lib
parent068b41275f6f142acfddca273ace68d03a6c0730 (diff)
parent9cfb253ed4ebf08c254db22c2da15a0b0d92c61e (diff)
downloadgitlab-ce-97041bb6c480e94593b1b7ee3102149ad30804dc.tar.gz
Merge branch 'fe-grammar-util' into 'master'
FE grammar util See merge request gitlab-org/gitlab-ce!24893
Diffstat (limited to 'spec/javascripts/lib')
-rw-r--r--spec/javascripts/lib/utils/grammar_spec.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/javascripts/lib/utils/grammar_spec.js b/spec/javascripts/lib/utils/grammar_spec.js
new file mode 100644
index 00000000000..377b2ffb48c
--- /dev/null
+++ b/spec/javascripts/lib/utils/grammar_spec.js
@@ -0,0 +1,35 @@
+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', () => {
+ const items = ['Lorem Ipsum'];
+
+ expect(grammar.toNounSeriesText(items)).toBe(items[0]);
+ });
+
+ it('with 2 items returns item1 and item2', () => {
+ const items = ['Dolar', 'Sit Amit'];
+
+ expect(grammar.toNounSeriesText(items)).toBe(`${items[0]} and ${items[1]}`);
+ });
+
+ it('with 3 items returns comma separated series', () => {
+ const items = ['Lorem', 'Ipsum', 'dolar'];
+ const expected = 'Lorem, Ipsum, and dolar';
+
+ expect(grammar.toNounSeriesText(items)).toBe(expected);
+ });
+
+ it('with 6 items returns comma separated series', () => {
+ const items = ['Lorem', 'ipsum', 'dolar', 'sit', 'amit', 'consectetur'];
+ const expected = 'Lorem, ipsum, dolar, sit, amit, and consectetur';
+
+ expect(grammar.toNounSeriesText(items)).toBe(expected);
+ });
+ });
+});