1- import { test , expect } from 'vitest'
1+ import { test , expect , describe } from 'vitest'
22import {
33 analyze ,
44 compareSpecificity ,
@@ -17,72 +17,109 @@ import {
1717 systemColors ,
1818 colorFunctions ,
1919 colorKeywords ,
20+ type UniqueWithLocations ,
21+ type Location ,
22+ type Specificity ,
2023} from './index.js'
2124
22- test ( "exposes the 'analyze' method" , ( ) => {
23- expect ( typeof analyze ) . toBe ( 'function' )
24- } )
25+ describe ( 'Public API' , ( ) => {
26+ test ( "exposes the 'analyze' method" , ( ) => {
27+ expect ( typeof analyze ) . toBe ( 'function' )
28+ } )
2529
26- test ( 'exposes the "compareSpecificity" method' , ( ) => {
27- expect ( typeof compareSpecificity ) . toBe ( 'function' )
28- } )
30+ test ( 'exposes the "compareSpecificity" method' , ( ) => {
31+ expect ( typeof compareSpecificity ) . toBe ( 'function' )
32+ } )
2933
30- test ( 'exposes the "selectorComplexity" method' , ( ) => {
31- expect ( typeof selectorComplexity ) . toBe ( 'function' )
32- } )
34+ test ( 'exposes the "selectorComplexity" method' , ( ) => {
35+ expect ( typeof selectorComplexity ) . toBe ( 'function' )
36+ } )
3337
34- test ( 'exposes the "isSelectorPrefixed" method' , ( ) => {
35- expect ( typeof isSelectorPrefixed ) . toBe ( 'function' )
36- } )
38+ test ( 'exposes the "isSelectorPrefixed" method' , ( ) => {
39+ expect ( typeof isSelectorPrefixed ) . toBe ( 'function' )
40+ } )
3741
38- test ( 'exposes the "isAccessibilitySelector" method' , ( ) => {
39- expect ( typeof isAccessibilitySelector ) . toBe ( 'function' )
40- } )
42+ test ( 'exposes the "isAccessibilitySelector" method' , ( ) => {
43+ expect ( typeof isAccessibilitySelector ) . toBe ( 'function' )
44+ } )
4145
42- test ( 'exposes the "isMediaBrowserhack" method' , ( ) => {
43- expect ( typeof isMediaBrowserhack ) . toBe ( 'function' )
44- } )
46+ test ( 'exposes the "isMediaBrowserhack" method' , ( ) => {
47+ expect ( typeof isMediaBrowserhack ) . toBe ( 'function' )
48+ } )
4549
46- test ( 'exposes the "isSupportsBrowserhack" method' , ( ) => {
47- expect ( typeof isSupportsBrowserhack ) . toBe ( 'function' )
48- } )
50+ test ( 'exposes the "isSupportsBrowserhack" method' , ( ) => {
51+ expect ( typeof isSupportsBrowserhack ) . toBe ( 'function' )
52+ } )
4953
50- test ( 'exposes the "isPropertyHack" method' , ( ) => {
51- expect ( typeof isPropertyHack ) . toBe ( 'function' )
52- } )
54+ test ( 'exposes the "isPropertyHack" method' , ( ) => {
55+ expect ( typeof isPropertyHack ) . toBe ( 'function' )
56+ } )
5357
54- test ( 'exposes the "isValuePrefixed" method' , ( ) => {
55- expect ( typeof isValuePrefixed ) . toBe ( 'function' )
56- } )
58+ test ( 'exposes the "isValuePrefixed" method' , ( ) => {
59+ expect ( typeof isValuePrefixed ) . toBe ( 'function' )
60+ } )
5761
58- test ( 'exposes the "hasVendorPrefix" method' , ( ) => {
59- expect ( typeof hasVendorPrefix ) . toBe ( 'function' )
60- } )
62+ test ( 'exposes the "hasVendorPrefix" method' , ( ) => {
63+ expect ( typeof hasVendorPrefix ) . toBe ( 'function' )
64+ } )
6165
62- test ( 'exposes the namedColors KeywordSet ' , ( ) => {
63- expect ( namedColors . has ( 'Red' ) ) . toBeTruthy ( )
64- } )
66+ test ( 'exposes the "compareSpecificity" method ' , ( ) => {
67+ expect ( typeof compareSpecificity ) . toBe ( 'function' )
68+ } )
6569
66- test ( 'exposes the systemColors KeywordSet' , ( ) => {
67- expect ( systemColors . has ( 'LinkText ' ) ) . toBeTruthy ( )
68- } )
70+ test ( 'exposes the namedColors KeywordSet' , ( ) => {
71+ expect ( namedColors . has ( 'Red ' ) ) . toBeTruthy ( )
72+ } )
6973
70- test ( 'exposes the colorFunctions KeywordSet' , ( ) => {
71- expect ( colorFunctions . has ( 'okLAB ' ) ) . toBeTruthy ( )
72- } )
74+ test ( 'exposes the systemColors KeywordSet' , ( ) => {
75+ expect ( systemColors . has ( 'LinkText ' ) ) . toBeTruthy ( )
76+ } )
7377
74- test ( 'exposes the colorKeywords KeywordSet' , ( ) => {
75- expect ( colorKeywords . has ( 'TRANSPARENT ' ) ) . toBeTruthy ( )
76- } )
78+ test ( 'exposes the colorFunctions KeywordSet' , ( ) => {
79+ expect ( colorFunctions . has ( 'okLAB ' ) ) . toBeTruthy ( )
80+ } )
7781
78- test ( 'exposes CSS keywords KeywordSet' , ( ) => {
79- expect ( cssKeywords . has ( 'Auto' ) ) . toBeTruthy ( )
80- expect ( cssKeywords . has ( 'inherit' ) ) . toBeTruthy ( )
81- } )
82+ test ( 'exposes the colorKeywords KeywordSet' , ( ) => {
83+ expect ( colorKeywords . has ( 'TRANSPARENT' ) ) . toBeTruthy ( )
84+ } )
85+
86+ test ( 'exposes CSS keywords KeywordSet' , ( ) => {
87+ expect ( cssKeywords . has ( 'Auto' ) ) . toBeTruthy ( )
88+ expect ( cssKeywords . has ( 'inherit' ) ) . toBeTruthy ( )
89+ } )
90+
91+ test ( 'exposes the KeywordSet class' , ( ) => {
92+ expect ( typeof KeywordSet ) . toBe ( 'function' )
93+ expect ( new KeywordSet ( [ ] ) . constructor . name ) . toBe ( 'KeywordSet' )
94+ } )
95+
96+ test ( 'exposes Location type' , ( ) => {
97+ let location : Location = {
98+ offset : 0 ,
99+ line : 0 ,
100+ length : 0 ,
101+ column : 0 ,
102+ }
103+ expect ( location ) . toHaveProperty ( 'line' )
104+ } )
105+
106+ test ( 'exposes UniqueWithLocations type' , ( ) => {
107+ let location : Location = {
108+ offset : 0 ,
109+ line : 0 ,
110+ length : 0 ,
111+ column : 0 ,
112+ }
113+ let uniqueWithLocations : UniqueWithLocations = {
114+ 'my-item' : [ location ] ,
115+ }
116+ expect ( uniqueWithLocations ) . toHaveProperty ( 'my-item' )
117+ } )
82118
83- test ( 'exposes the KeywordSet class' , ( ) => {
84- expect ( typeof KeywordSet ) . toBe ( 'function' )
85- expect ( new KeywordSet ( [ ] ) . constructor . name ) . toBe ( 'KeywordSet' )
119+ test ( 'exposes Specificity type' , ( ) => {
120+ let specificity : Specificity = [ 1 , 1 , 1 ]
121+ expect ( specificity ) . toHaveLength ( 3 )
122+ } )
86123} )
87124
88125test ( 'does not break on CSS Syntax Errors' , ( ) => {
0 commit comments