@@ -2,6 +2,7 @@ import { assert } from "chai";
22import { CSSProperties } from "react" ;
33
44import { transit , resolveTransit } from "./transit" ;
5+ import pick from "./utils/pick" ;
56
67describe ( "transit.ts" , ( ) => {
78 describe ( "transit" , ( ) => {
@@ -42,6 +43,10 @@ describe("transit.ts", () => {
4243 assert . strictEqual ( result . transition , "width 50ms ease 20ms" ) ;
4344 } ) ;
4445
46+ it ( "should set WebkitTransition" , ( ) => {
47+ assert . strictEqual ( ( result as any ) . WebkitTransition , "width 50ms ease 20ms" ) ;
48+ } ) ;
49+
4550 it ( "should leave other properties untouched" , ( ) => {
4651 assert . strictEqual ( result . height , "25px" ) ;
4752 } ) ;
@@ -70,28 +75,53 @@ describe("transit.ts", () => {
7075 "width 120ms ease 30ms, background 100ms linear 20ms" ) ;
7176 } ) ;
7277
78+ it ( "should set WebkitTransition" , ( ) => {
79+ assert . strictEqual ( ( result as any ) . WebkitTransition ,
80+ "width 120ms ease 30ms, background 100ms linear 20ms" ) ;
81+ } ) ;
82+
7383 it ( "should leave other properties untouched" , ( ) => {
7484 assert . strictEqual ( result . height , "25px" ) ;
7585 } ) ;
7686 } ) ;
7787
78- describe ( "when processing style with single transition and vendor prefix " , ( ) => {
88+ describe ( "when processing style with multiple transition and vendor prefixes " , ( ) => {
7989 let style : CSSProperties ;
8090 let result : CSSProperties ;
8191
8292 before ( ( ) => {
8393 style = {
84- WebkitTransform : transit ( "50px" , 50 , "ease" , 20 ) ,
94+ top : transit ( "50px" , 50 ) ,
95+ WebkitTransform : transit ( "scale(1.0)" , 50 ) ,
96+ MozTransform : transit ( "scale(1.0)" , 50 ) ,
97+ transform : transit ( "scale(1.0)" , 50 ) ,
8598 } ;
8699 result = resolveTransit ( style ) ;
87100 } ) ;
88101
89102 it ( "should turn TransitionConfig to value" , ( ) => {
90- assert . strictEqual ( result [ "WebkitTransform" ] , "50px" ) ;
103+ assert . deepEqual ( pick ( result , ...Object . keys ( style ) ) , {
104+ top : "50px" ,
105+ WebkitTransform : "scale(1.0)" ,
106+ MozTransform : "scale(1.0)" ,
107+ transform : "scale(1.0)" ,
108+ } ) ;
91109 } ) ;
92110
93111 it ( "should set transition with css prefix" , ( ) => {
94- assert . strictEqual ( result . transition , "-webkit-transform 50ms ease 20ms" ) ;
112+ assert . strictEqual ( result . transition ,
113+ [ "top" , "-webkit-transform" , "-moz-transform" , "transform" ] .
114+ map ( ( p ) => `${ p } 50ms ease 0ms` ) .
115+ join ( ", " ) ,
116+ ) ;
117+ } ) ;
118+
119+ it ( "should set WebkitTransition" , ( ) => {
120+ assert . strictEqual ( ( result as any ) . WebkitTransition ,
121+ [ "top" , "-webkit-transform" ] .
122+ map ( ( p ) => `${ p } 50ms ease 0ms` ) .
123+ join ( ", " ) ,
124+ ) ;
95125 } ) ;
96126 } ) ;
97127
0 commit comments