File tree Expand file tree Collapse file tree 3 files changed +34
-11
lines changed Expand file tree Collapse file tree 3 files changed +34
-11
lines changed Original file line number Diff line number Diff line change
1
+ import transformCss from '..'
2
+
3
+ it ( 'transforms hex colors' , ( ) => {
4
+ expect ( transformCss ( [ [ 'color' , '#f00' ] ] ) ) . toEqual ( { color : '#f00' } )
5
+ } )
6
+
7
+ it ( 'transforms rgb colors' , ( ) => {
8
+ expect ( transformCss ( [ [ 'color' , 'rgb(255, 0, 0)' ] ] ) ) . toEqual ( {
9
+ color : 'rgb(255, 0, 0)' ,
10
+ } )
11
+ } )
12
+
13
+ it ( 'transforms transparent color' , ( ) => {
14
+ expect ( transformCss ( [ [ 'color' , 'transparent' ] ] ) ) . toEqual ( {
15
+ color : 'transparent' ,
16
+ } )
17
+ } )
18
+
19
+ it ( 'transforms border shorthand with transparent color' , ( ) => {
20
+ expect ( transformCss ( [ [ 'border' , '2px dashed transparent' ] ] ) ) . toEqual ( {
21
+ borderColor : 'transparent' ,
22
+ borderStyle : 'dashed' ,
23
+ borderWidth : 2 ,
24
+ } )
25
+ } )
26
+
27
+ it ( 'transforms background shorthand with transparent color' , ( ) => {
28
+ expect ( transformCss ( [ [ 'background' , 'transparent' ] ] ) ) . toEqual ( {
29
+ backgroundColor : 'transparent' ,
30
+ } )
31
+ } )
Original file line number Diff line number Diff line change @@ -117,16 +117,6 @@ it('transforms strings', () => {
117
117
expect ( transformCss ( [ [ 'color' , 'red' ] ] ) ) . toEqual ( { color : 'red' } )
118
118
} )
119
119
120
- it ( 'transforms hex colors' , ( ) => {
121
- expect ( transformCss ( [ [ 'color' , '#f00' ] ] ) ) . toEqual ( { color : '#f00' } )
122
- } )
123
-
124
- it ( 'transforms rgb colors' , ( ) => {
125
- expect ( transformCss ( [ [ 'color' , 'rgb(255, 0, 0)' ] ] ) ) . toEqual ( {
126
- color : 'rgb(255, 0, 0)' ,
127
- } )
128
- } )
129
-
130
120
it ( 'converts to camel-case' , ( ) => {
131
121
expect ( transformCss ( [ [ 'background-color' , 'red' ] ] ) ) . toEqual ( {
132
122
backgroundColor : 'red' ,
Original file line number Diff line number Diff line change @@ -16,7 +16,9 @@ const cssFunctionNameRe = /^(rgba?|hsla?|hwb|lab|lch|gray|color)$/
16
16
const matchColor = node => {
17
17
if (
18
18
node . type === 'word' &&
19
- ( hexColorRe . test ( node . value ) || node . value in cssColorKeywords )
19
+ ( hexColorRe . test ( node . value ) ||
20
+ node . value in cssColorKeywords ||
21
+ node . value === 'transparent' )
20
22
) {
21
23
return node . value
22
24
} else if ( node . type === 'function' && cssFunctionNameRe . test ( node . value ) ) {
You can’t perform that action at this time.
0 commit comments