@@ -190,3 +190,79 @@ defineTest({
190
190
expect ( ids3 ) . not . toContainEqual ( expect . toBeOneOf ( ids2 ) )
191
191
} ,
192
192
} )
193
+
194
+ defineTest ( {
195
+ name : 'Creating a CSS config in an empty folder initalizes a project' ,
196
+ fs : {
197
+ 'app.css' : css `
198
+ /* this file is not a Tailwind CSS config yet */
199
+ ` ,
200
+ } ,
201
+ prepare : async ( { root } ) => ( {
202
+ client : await createClient ( { root, log : true } ) ,
203
+ } ) ,
204
+ handle : async ( { root, client } ) => {
205
+ let doc = await client . open ( {
206
+ lang : 'html' ,
207
+ text : '<div class="text-primary">' ,
208
+ } )
209
+
210
+ // <div class="text-primary">
211
+ // ^
212
+ let hover = await doc . hover ( { line : 0 , character : 13 } )
213
+
214
+ expect ( hover ) . toEqual ( null )
215
+
216
+ // Create a CSS config file
217
+ await fs . writeFile (
218
+ `${ root } /app.css` ,
219
+ css `
220
+ @import 'tailwindcss';
221
+
222
+ @theme {
223
+ --color-primary: #c0ffee;
224
+ }
225
+ ` ,
226
+ )
227
+
228
+ // Create a CSS config file
229
+ // Notify the server of the config change
230
+ let didRestart = Promise . race ( [
231
+ new Promise ( ( resolve ) => {
232
+ client . conn . onNotification ( '@/tailwindCSS/serverRestarted' , resolve )
233
+ } ) ,
234
+ new Promise ( ( _ , reject ) =>
235
+ setTimeout ( ( ) => reject ( new Error ( 'Did not restart in time' ) ) , 5000 ) ,
236
+ ) ,
237
+ ] )
238
+
239
+ await client . notifyChangedFiles ( {
240
+ changed : [ `${ root } /app.css` ] ,
241
+ } )
242
+
243
+ await didRestart
244
+
245
+ // TODO: Sending a shutdown request immediately after a restart
246
+ // gets lost
247
+ // await client.shutdown()
248
+
249
+ // <div class="text-primary">
250
+ // ^
251
+ hover = await doc . hover ( { line : 0 , character : 13 } )
252
+
253
+ expect ( hover ) . toEqual ( {
254
+ contents : {
255
+ language : 'css' ,
256
+ value : dedent `
257
+ .text-primary {
258
+ color: var(--color-primary) /* #c0ffee */;
259
+ }
260
+ ` ,
261
+ } ,
262
+ range : {
263
+ start : { line : 0 , character : 12 } ,
264
+ end : { line : 0 , character : 24 } ,
265
+ } ,
266
+ } )
267
+ } ,
268
+ } )
0 commit comments