Skip to content

Commit b09b295

Browse files
authored
Test suggestionList more thoroughly (#3241)
Particularly, verify that it first sorts by lexicographic distance and then naturally.
1 parent 0e22cc4 commit b09b295

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

src/jsutils/__tests__/suggestionList-test.ts

+32-1
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,44 @@ describe('suggestionList', () => {
5757
'ab',
5858
'a',
5959
]);
60+
61+
expectSuggestions('GraphQl', [
62+
'graphics',
63+
'SQL',
64+
'GraphQL',
65+
'quarks',
66+
'mark',
67+
]).to.deep.equal(['GraphQL', 'graphics']);
6068
});
6169

62-
it('Returns options with the same lexical distance sorted lexicographically', () => {
70+
it('Returns options with the same lexical distance sorted naturally', () => {
6371
expectSuggestions('a', ['az', 'ax', 'ay']).to.deep.equal([
6472
'ax',
6573
'ay',
6674
'az',
6775
]);
76+
77+
expectSuggestions('boo', ['moo', 'foo', 'zoo']).to.deep.equal([
78+
'foo',
79+
'moo',
80+
'zoo',
81+
]);
82+
83+
expectSuggestions('abc', ['a1', 'a12', 'a2']).to.deep.equal([
84+
'a1',
85+
'a2',
86+
'a12',
87+
]);
88+
});
89+
90+
it('Returns options sorted first by lexical distance then naturally', () => {
91+
// cSpell:ignore csutomer, stomer
92+
expectSuggestions('csutomer', [
93+
'store',
94+
'customer',
95+
'stomer',
96+
'some',
97+
'more',
98+
]).to.deep.equal(['customer', 'stomer', 'some', 'store']);
6899
});
69100
});

0 commit comments

Comments
 (0)