@@ -7,7 +7,7 @@ import * as ac from "atom/autocomplete-plus"
7
7
import { expect } from "chai"
8
8
import { createSpyConnection , createFakeEditor } from "../helpers.js"
9
9
import { TextSuggestion , SnippetSuggestion } from "../../lib/types/autocomplete-extended"
10
- import { CompletionItem } from "../../lib/languageclient"
10
+ import { CompletionItem , Range } from "../../lib/languageclient"
11
11
12
12
function createRequest ( {
13
13
prefix = "" ,
@@ -94,6 +94,23 @@ describe("AutoCompleteAdapter", () => {
94
94
documentation : "should not appear" ,
95
95
sortText : "zzz" ,
96
96
} ,
97
+ {
98
+ label : "snippet5" ,
99
+ kind : ls . CompletionItemKind . Snippet ,
100
+ textEdit : {
101
+ newText : "snippet5NewText" ,
102
+ range : Range . create ( { line : 0 , character : 0 } , { line : 0 , character : 14 } ) ,
103
+ } ,
104
+ } ,
105
+ {
106
+ label : "snippet6" ,
107
+ kind : ls . CompletionItemKind . Snippet ,
108
+ textEdit : {
109
+ newText : "snippet6newText" ,
110
+ replace : Range . create ( { line : 0 , character : 0 } , { line : 0 , character : 14 } ) ,
111
+ insert : Range . create ( { line : 0 , character : 0 } , { line : 0 , character : 14 } ) ,
112
+ } ,
113
+ } ,
97
114
]
98
115
99
116
const request = createRequest ( { prefix : "lab" } )
@@ -114,6 +131,12 @@ describe("AutoCompleteAdapter", () => {
114
131
expect ( resultsLab . length ) . equals ( 2 )
115
132
expect ( resultsLab . some ( ( r ) => r . displayText === "thisHasFiltertext" ) ) . to . be . true
116
133
expect ( resultsLab . some ( ( r ) => r . displayText === "label3" ) ) . to . be . true
134
+
135
+ const resultsSnip = await getSuggestionsMock ( completionItems , createRequest ( { prefix : "snip" } ) )
136
+ expect ( resultsSnip . length ) . equals ( 2 )
137
+ expect (
138
+ resultsSnip . filter ( ( r ) => r . displayText !== undefined && [ "snippet5" , "snippet6" ] . includes ( r . displayText ) )
139
+ ) . to . have . lengthOf ( 2 )
117
140
} )
118
141
119
142
it ( "uses the sortText property to arrange completions when there is no prefix" , async ( ) => {
0 commit comments