@@ -182,3 +182,65 @@ defineTest({
182
182
expect ( idsBefore ) . toEqual ( idsAfter )
183
183
} ,
184
184
} )
185
+
186
+ defineTest ( {
187
+ name : 'Trigger characters are registered after a server restart' ,
188
+ fs : {
189
+ 'app.css' : '@import "tailwindcss"' ,
190
+ } ,
191
+ prepare : async ( { root } ) => ( { client : await createClient ( { root } ) } ) ,
192
+ handle : async ( { root, client } ) => {
193
+ // Initially don't have any registered capabilities because dynamic
194
+ // registration is delayed until after project initialization
195
+ expect ( client . serverCapabilities ) . toEqual ( [ ] )
196
+
197
+ // We open a document so a project gets initialized
198
+ await client . open ( {
199
+ lang : 'html' ,
200
+ text : '<div class="bg-[#000]/25 hover:">' ,
201
+ } )
202
+
203
+ // And now capabilities are registered
204
+ expect ( client . serverCapabilities ) . toEqual (
205
+ expect . arrayContaining ( [
206
+ expect . objectContaining ( {
207
+ method : 'textDocument/hover' ,
208
+ } ) ,
209
+
210
+ expect . objectContaining ( {
211
+ method : 'textDocument/completion' ,
212
+ registerOptions : {
213
+ documentSelector : null ,
214
+ resolveProvider : true ,
215
+ triggerCharacters : [ '"' , "'" , '`' , ' ' , '.' , '(' , '[' , ']' , '!' , '/' , '-' , ':' ] ,
216
+ } ,
217
+ } ) ,
218
+ ] ) ,
219
+ )
220
+
221
+ let didRestart = new Promise ( ( resolve ) => {
222
+ client . conn . onNotification ( '@/tailwindCSS/serverRestarted' , resolve )
223
+ } )
224
+
225
+ // Force a server restart by telling the server tsconfig.json changed
226
+ client . notifyChangedFiles ( {
227
+ changed : [ `${ root } /tsconfig.json` ] ,
228
+ } )
229
+
230
+ // Wait for the server initialization to finish
231
+ await didRestart
232
+
233
+ expect ( client . serverCapabilities ) . toEqual (
234
+ expect . arrayContaining ( [
235
+ expect . objectContaining ( {
236
+ method : 'textDocument/completion' ,
237
+ registerOptions : {
238
+ documentSelector : null ,
239
+ resolveProvider : true ,
240
+ triggerCharacters : [ '"' , "'" , '`' , ' ' , '.' , '(' , '[' , ']' , '!' , '/' , '-' , ':' ] ,
241
+ } ,
242
+ } ) ,
243
+ ] ) ,
244
+ )
245
+ } ,
246
+ } )
0 commit comments