@@ -246,18 +246,27 @@ describe('common', () => {
246
246
value : '#FF0000' ,
247
247
comment : 'Foo bar qux' ,
248
248
path : [ 'color' , 'red' ] ,
249
+ original : {
250
+ value : '#FF0000' ,
251
+ } ,
249
252
} ,
250
253
green : {
251
254
name : 'color-green' ,
252
255
value : '#00FF00' ,
253
256
comment : 'Foo bar qux' ,
254
257
path : [ 'color' , 'green' ] ,
258
+ original : {
259
+ value : '#00FF00' ,
260
+ } ,
255
261
} ,
256
262
blue : {
257
263
name : 'color-blue' ,
258
264
value : '#0000FF' ,
259
265
comment : 'Foo\nbar\nqux' ,
260
266
path : [ 'color' , 'blue' ] ,
267
+ original : {
268
+ value : '#0000FF' ,
269
+ } ,
261
270
} ,
262
271
} ,
263
272
} ;
@@ -307,44 +316,79 @@ describe('common', () => {
307
316
await expect ( cssRed ) . to . matchSnapshot ( 1 ) ;
308
317
await expect ( sassRed ) . to . matchSnapshot ( 2 ) ;
309
318
} ) ;
319
+ } ) ;
310
320
311
- it ( 'supports DTCG spec $description property for comments' , async ( ) => {
312
- const descriptionDictionary = {
313
- color : {
314
- red : {
315
- name : 'color-red' ,
316
- value : '#FF0000' ,
317
- $description : 'Foo bar qux red' ,
318
- path : [ 'color' , 'red' ] ,
321
+ describe ( ' DTCG' , ( ) => {
322
+ const dtcgDictionary = {
323
+ color : {
324
+ red : {
325
+ name : 'color-red' ,
326
+ $ value : '#FF0000' ,
327
+ original : {
328
+ $value : '#FF0000' ,
319
329
} ,
320
- green : {
321
- name : 'color-green' ,
322
- value : '#00FF00' ,
323
- $description : 'Foo bar qux green' ,
324
- path : [ 'color' , 'green' ] ,
330
+ $description : 'Foo bar qux red' ,
331
+ path : [ 'color' , 'red' ] ,
332
+ } ,
333
+ green : {
334
+ name : 'color-green' ,
335
+ $value : '#00FF00' ,
336
+ original : {
337
+ $value : '#00FF00' ,
325
338
} ,
326
- blue : {
327
- name : 'color-blue' ,
328
- value : '#0000FF' ,
329
- $description : 'Foo\nbar\nqux\nblue' ,
330
- path : [ 'color' , 'blue' ] ,
339
+ $description : 'Foo bar qux green' ,
340
+ path : [ 'color' , 'green' ] ,
341
+ } ,
342
+ blue : {
343
+ name : 'color-blue' ,
344
+ $value : '#0000FF' ,
345
+ original : {
346
+ $value : '#0000FF' ,
331
347
} ,
348
+ $description : 'Foo\nbar\nqux\nblue' ,
349
+ path : [ 'color' , 'blue' ] ,
332
350
} ,
333
- } ;
351
+ ref : {
352
+ name : 'color-ref' ,
353
+ $value : '#FF0000' ,
354
+ original : {
355
+ $value : '{color.red}' ,
356
+ } ,
357
+ $description : 'Foo\nbar\nqux\nref' ,
358
+ path : [ 'color' , 'ref' ] ,
359
+ } ,
360
+ } ,
361
+ } ;
362
+ it ( 'supports DTCG spec $description property for comments' , async ( ) => {
334
363
// long commentStyle
335
364
const cssFormatter = createPropertyFormatter ( {
336
365
format : 'css' ,
337
- dictionary : { tokens : descriptionDictionary } ,
366
+ dictionary : { tokens : dtcgDictionary } ,
367
+ usesDtcg : true ,
338
368
} ) ;
339
369
340
- const cssRed = cssFormatter ( descriptionDictionary . color . red ) ;
341
- const cssGreen = cssFormatter ( descriptionDictionary . color . green ) ;
342
- const cssBlue = cssFormatter ( descriptionDictionary . color . blue ) ;
370
+ const cssRed = cssFormatter ( dtcgDictionary . color . red ) ;
371
+ const cssGreen = cssFormatter ( dtcgDictionary . color . green ) ;
372
+ const cssBlue = cssFormatter ( dtcgDictionary . color . blue ) ;
343
373
344
374
await expect ( cssRed ) . to . matchSnapshot ( 1 ) ;
345
375
await expect ( cssGreen ) . to . matchSnapshot ( 2 ) ;
346
376
await expect ( cssBlue ) . to . matchSnapshot ( 3 ) ;
347
377
} ) ;
378
+
379
+ it ( 'supports DTCG spec $value for outputReferences' , async ( ) => {
380
+ // long commentStyle
381
+ const cssFormatter = createPropertyFormatter ( {
382
+ format : 'css' ,
383
+ outputReferences : true ,
384
+ dictionary : { tokens : dtcgDictionary } ,
385
+ usesDtcg : true ,
386
+ } ) ;
387
+
388
+ const cssRef = cssFormatter ( dtcgDictionary . color . ref ) ;
389
+
390
+ await expect ( cssRef ) . to . matchSnapshot ( ) ;
391
+ } ) ;
348
392
} ) ;
349
393
} ) ;
350
394
} ) ;
0 commit comments