1*6fb32dddSKeith Kurakimport { joinWithCommasAnd } from '../strings';
2*6fb32dddSKeith Kurak
3*6fb32dddSKeith Kurakdescribe(joinWithCommasAnd, () => {
4*6fb32dddSKeith Kurak  it(`joins 3+ items with an oxford comma`, () => {
5*6fb32dddSKeith Kurak    expect(joinWithCommasAnd(['a', 'b', 'c'])).toEqual('a, b, and c');
6*6fb32dddSKeith Kurak  });
7*6fb32dddSKeith Kurak
8*6fb32dddSKeith Kurak  it(`joins 2 items with an 'and'`, () => {
9*6fb32dddSKeith Kurak    expect(joinWithCommasAnd(['a', 'b'])).toEqual('a and b');
10*6fb32dddSKeith Kurak  });
11*6fb32dddSKeith Kurak
12*6fb32dddSKeith Kurak  it(`returns a single item`, () => {
13*6fb32dddSKeith Kurak    expect(joinWithCommasAnd(['a'])).toEqual('a');
14*6fb32dddSKeith Kurak  });
15*6fb32dddSKeith Kurak
16*6fb32dddSKeith Kurak  it(`returns an empty string for zero items`, () => {
17*6fb32dddSKeith Kurak    expect(joinWithCommasAnd([])).toEqual('');
18*6fb32dddSKeith Kurak  });
19*6fb32dddSKeith Kurak
20*6fb32dddSKeith Kurak  it(`joins limit+1 with 'and 1 other'`, () => {
21*6fb32dddSKeith Kurak    expect(joinWithCommasAnd(['a', 'b', 'c', 'd', 'e'], 4)).toEqual('a, b, c, d, and 1 other');
22*6fb32dddSKeith Kurak  });
23*6fb32dddSKeith Kurak
24*6fb32dddSKeith Kurak  it(`joins limit+1 with 'and 1 other'`, () => {
25*6fb32dddSKeith Kurak    expect(joinWithCommasAnd(['a', 'b', 'c', 'd', 'e'], 4)).toEqual('a, b, c, d, and 1 other');
26*6fb32dddSKeith Kurak  });
27*6fb32dddSKeith Kurak
28*6fb32dddSKeith Kurak  it(`joins limit+2 or more with 'and x others'`, () => {
29*6fb32dddSKeith Kurak    expect(joinWithCommasAnd(['a', 'b', 'c', 'd', 'e', 'f'], 4)).toEqual(
30*6fb32dddSKeith Kurak      'a, b, c, d, and 2 others'
31*6fb32dddSKeith Kurak    );
32*6fb32dddSKeith Kurak  });
33*6fb32dddSKeith Kurak
34*6fb32dddSKeith Kurak  it(`eliminates duplicates`, () => {
35*6fb32dddSKeith Kurak    expect(joinWithCommasAnd(['a', 'c', 'b', 'c'])).toEqual('a, c, and b');
36*6fb32dddSKeith Kurak  });
37*6fb32dddSKeith Kurak});
38