forked from graphql/graphql-js
/
didYouMean-test.js
36 lines (29 loc) · 934 Bytes
/
didYouMean-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { expect } from 'chai';
import { describe, it } from 'mocha';
import { didYouMean } from '../didYouMean';
describe('didYouMean', () => {
it('Does accept an empty list', () => {
expect(didYouMean([])).to.equal('');
});
it('Handles single suggestion', () => {
expect(didYouMean(['A'])).to.equal(' Did you mean "A"?');
});
it('Handles two suggestions', () => {
expect(didYouMean(['A', 'B'])).to.equal(' Did you mean "A" or "B"?');
});
it('Handles multiple suggestions', () => {
expect(didYouMean(['A', 'B', 'C'])).to.equal(
' Did you mean "A", "B", or "C"?',
);
});
it('Limits to five suggestions', () => {
expect(didYouMean(['A', 'B', 'C', 'D', 'E', 'F'])).to.equal(
' Did you mean "A", "B", "C", "D", or "E"?',
);
});
it('Adds sub-message', () => {
expect(didYouMean('the letter', ['A'])).to.equal(
' Did you mean the letter "A"?',
);
});
});