Skip to content

Commit

Permalink
Test suggestionList more thoroughly (graphql#3241)
Browse files Browse the repository at this point in the history
Particularly, verify that it first sorts by lexicographic distance and then naturally.
  • Loading branch information
Cito authored Sep 30, 2024
1 parent 0e22cc4 commit b09b295
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion src/jsutils/__tests__/suggestionList-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,44 @@ describe('suggestionList', () => {
'ab',
'a',
]);

expectSuggestions('GraphQl', [
'graphics',
'SQL',
'GraphQL',
'quarks',
'mark',
]).to.deep.equal(['GraphQL', 'graphics']);
});

it('Returns options with the same lexical distance sorted lexicographically', () => {
it('Returns options with the same lexical distance sorted naturally', () => {
expectSuggestions('a', ['az', 'ax', 'ay']).to.deep.equal([
'ax',
'ay',
'az',
]);

expectSuggestions('boo', ['moo', 'foo', 'zoo']).to.deep.equal([
'foo',
'moo',
'zoo',
]);

expectSuggestions('abc', ['a1', 'a12', 'a2']).to.deep.equal([
'a1',
'a2',
'a12',
]);
});

it('Returns options sorted first by lexical distance then naturally', () => {
// cSpell:ignore csutomer, stomer
expectSuggestions('csutomer', [
'store',
'customer',
'stomer',
'some',
'more',
]).to.deep.equal(['customer', 'stomer', 'some', 'store']);
});
});

0 comments on commit b09b295

Please sign in to comment.