@@ -6,6 +6,14 @@ import { style } from './style';
66setFileScope ( 'test' ) ;
77
88const testVar = createVar ( ) ;
9+ const testPropertyVar = createVar (
10+ {
11+ syntax : '<angle>' ,
12+ inherits : false ,
13+ initialValue : '0deg' ,
14+ } ,
15+ 'test-property' ,
16+ ) ;
917const style1 = style ( { } ) ;
1018const style2 = style ( { } ) ;
1119
@@ -1845,6 +1853,46 @@ describe('transformCss', () => {
18451853 ` ) ;
18461854 } ) ;
18471855
1856+ it ( 'should handle animations with vars' , ( ) => {
1857+ expect (
1858+ transformCss ( {
1859+ composedClassLists : [ ] ,
1860+ localClassNames : [ 'testClass' ] ,
1861+ cssObjs : [
1862+ {
1863+ type : 'keyframes' ,
1864+ name : 'myAnimation' ,
1865+ rule : {
1866+ from : {
1867+ vars : {
1868+ '--my-var' : 'red' ,
1869+ [ testVar ] : 'green' ,
1870+ } ,
1871+ } ,
1872+ to : {
1873+ vars : {
1874+ '--my-var' : 'orange' ,
1875+ [ testVar ] : 'blue' ,
1876+ } ,
1877+ } ,
1878+ } ,
1879+ } ,
1880+ ] ,
1881+ } ) . join ( '\n' ) ,
1882+ ) . toMatchInlineSnapshot ( `
1883+ @keyframes myAnimation {
1884+ from {
1885+ --my-var: red;
1886+ --skkcyc0: green;
1887+ }
1888+ to {
1889+ --my-var: orange;
1890+ --skkcyc0: blue;
1891+ }
1892+ }
1893+ ` ) ;
1894+ } ) ;
1895+
18481896 it ( 'should handle font face' , ( ) => {
18491897 expect (
18501898 transformCss ( {
@@ -2022,7 +2070,7 @@ describe('transformCss', () => {
20222070 ` ) ;
20232071 } ) ;
20242072
2025- it ( 'should handle css vars ' , ( ) => {
2073+ it ( 'should handle simple css properties ' , ( ) => {
20262074 expect (
20272075 transformCss ( {
20282076 composedClassLists : [ ] ,
@@ -2076,6 +2124,60 @@ describe('transformCss', () => {
20762124 ` ) ;
20772125 } ) ;
20782126
2127+ it ( 'should handle complicated css properties' , ( ) => {
2128+ expect (
2129+ transformCss ( {
2130+ composedClassLists : [ ] ,
2131+ localClassNames : [ 'testClass' ] ,
2132+ cssObjs : [
2133+ {
2134+ type : 'local' ,
2135+ selector : 'testClass' ,
2136+ rule : {
2137+ display : 'block' ,
2138+ vars : {
2139+ '--my-var' : 'red' ,
2140+ [ testPropertyVar ] : '10deg' ,
2141+ } ,
2142+ selectors : {
2143+ '&:nth-child(3)' : {
2144+ vars : {
2145+ '--my-var' : 'orange' ,
2146+ [ testPropertyVar ] : '20deg' ,
2147+ } ,
2148+ } ,
2149+ } ,
2150+ '@media' : {
2151+ 'screen and (min-width: 700px)' : {
2152+ vars : {
2153+ '--my-var' : 'yellow' ,
2154+ [ testPropertyVar ] : '50deg' ,
2155+ } ,
2156+ } ,
2157+ } ,
2158+ } ,
2159+ } ,
2160+ ] ,
2161+ } ) . join ( '\n' ) ,
2162+ ) . toMatchInlineSnapshot ( `
2163+ .testClass {
2164+ --my-var: red;
2165+ --test-property__skkcyc1: 10deg;
2166+ display: block;
2167+ }
2168+ .testClass:nth-child(3) {
2169+ --my-var: orange;
2170+ --test-property__skkcyc1: 20deg;
2171+ }
2172+ @media screen and (min-width: 700px) {
2173+ .testClass {
2174+ --my-var: yellow;
2175+ --test-property__skkcyc1: 50deg;
2176+ }
2177+ }
2178+ ` ) ;
2179+ } ) ;
2180+
20792181 it ( 'should cast property values to pixels when relevant' , ( ) => {
20802182 expect (
20812183 transformCss ( {
@@ -2288,13 +2390,13 @@ describe('transformCss', () => {
22882390 ] ,
22892391 } ) . join ( '\n' ) ,
22902392 ) . toMatchInlineSnapshot ( `
2291- .skkcyc2 .skkcyc1 :before, .skkcyc2 .skkcyc1 :after {
2393+ .skkcyc3 .skkcyc2 :before, .skkcyc3 .skkcyc2 :after {
22922394 background: black;
22932395 }
2294- ._1g1ptzo1._1g1ptzo10 .skkcyc1 {
2396+ ._1g1ptzo1._1g1ptzo10 .skkcyc2 {
22952397 background: blue;
22962398 }
2297- ._1g1ptzo10._1g1ptzo1 .skkcyc1 {
2399+ ._1g1ptzo10._1g1ptzo1 .skkcyc2 {
22982400 background: blue;
22992401 }
23002402 ` ) ;
0 commit comments