@@ -5,52 +5,50 @@ import { describe, it } from 'mocha';
5
5
6
6
import suggestionList from '../suggestionList' ;
7
7
8
+ function expectSuggestions ( input , options ) {
9
+ return expect ( suggestionList ( input , options ) ) ;
10
+ }
11
+
8
12
describe ( 'suggestionList' , ( ) => {
9
13
it ( 'Returns results when input is empty' , ( ) => {
10
- expect ( suggestionList ( '' , [ 'a' ] ) ) . to . deep . equal ( [ 'a' ] ) ;
14
+ expectSuggestions ( '' , [ 'a' ] ) . to . deep . equal ( [ 'a' ] ) ;
11
15
} ) ;
12
16
13
17
it ( 'Returns empty array when there are no options' , ( ) => {
14
- expect ( suggestionList ( 'input' , [ ] ) ) . to . deep . equal ( [ ] ) ;
18
+ expectSuggestions ( 'input' , [ ] ) . to . deep . equal ( [ ] ) ;
15
19
} ) ;
16
20
17
21
it ( 'Returns options with small lexical distance' , ( ) => {
18
- expect ( suggestionList ( 'greenish' , [ 'green' ] ) ) . to . deep . equal ( [ 'green' ] ) ;
19
- expect ( suggestionList ( 'green' , [ 'greenish' ] ) ) . to . deep . equal ( [ 'greenish' ] ) ;
22
+ expectSuggestions ( 'greenish' , [ 'green' ] ) . to . deep . equal ( [ 'green' ] ) ;
23
+ expectSuggestions ( 'green' , [ 'greenish' ] ) . to . deep . equal ( [ 'greenish' ] ) ;
20
24
} ) ;
21
25
22
26
it ( 'Returns options with different case' , ( ) => {
23
27
// cSpell:ignore verylongstring
24
- expect ( suggestionList ( 'verylongstring' , [ 'VERYLONGSTRING' ] ) ) . to . deep . equal ( [
28
+ expectSuggestions ( 'verylongstring' , [ 'VERYLONGSTRING' ] ) . to . deep . equal ( [
25
29
'VERYLONGSTRING' ,
26
30
] ) ;
27
31
28
- expect ( suggestionList ( 'VERYLONGSTRING' , [ 'verylongstring' ] ) ) . to . deep . equal ( [
32
+ expectSuggestions ( 'VERYLONGSTRING' , [ 'verylongstring' ] ) . to . deep . equal ( [
29
33
'verylongstring' ,
30
34
] ) ;
31
35
32
- expect ( suggestionList ( 'VERYLONGSTRING' , [ 'VeryLongString' ] ) ) . to . deep . equal ( [
36
+ expectSuggestions ( 'VERYLONGSTRING' , [ 'VeryLongString' ] ) . to . deep . equal ( [
33
37
'VeryLongString' ,
34
38
] ) ;
35
39
} ) ;
36
40
37
41
it ( 'Returns options with transpositions' , ( ) => {
38
- expect ( suggestionList ( 'agr' , [ 'arg' ] ) ) . to . deep . equal ( [ 'arg' ] ) ;
39
-
40
- expect ( suggestionList ( '214365879' , [ '123456789' ] ) ) . to . deep . equal ( [
41
- '123456789' ,
42
- ] ) ;
42
+ expectSuggestions ( 'agr' , [ 'arg' ] ) . to . deep . equal ( [ 'arg' ] ) ;
43
+ expectSuggestions ( '214365879' , [ '123456789' ] ) . to . deep . equal ( [ '123456789' ] ) ;
43
44
} ) ;
44
45
45
46
it ( 'Returns options sorted based on lexical distance' , ( ) => {
46
- expect ( suggestionList ( 'abc' , [ 'a' , 'ab' , 'abc' ] ) ) . to . deep . equal ( [
47
- 'abc' ,
48
- 'ab' ,
49
- ] ) ;
47
+ expectSuggestions ( 'abc' , [ 'a' , 'ab' , 'abc' ] ) . to . deep . equal ( [ 'abc' , 'ab' ] ) ;
50
48
} ) ;
51
49
52
50
it ( 'Returns options with the same lexical distance sorted lexicographically' , ( ) => {
53
- expect ( suggestionList ( 'a' , [ 'az' , 'ax' , 'ay' ] ) ) . to . deep . equal ( [
51
+ expectSuggestions ( 'a' , [ 'az' , 'ax' , 'ay' ] ) . to . deep . equal ( [
54
52
'ax' ,
55
53
'ay' ,
56
54
'az' ,
0 commit comments