@@ -2,6 +2,7 @@ import { assert } from "chai";
2
2
import { CSSProperties } from "react" ;
3
3
4
4
import { transit , resolveTransit } from "./transit" ;
5
+ import pick from "./utils/pick" ;
5
6
6
7
describe ( "transit.ts" , ( ) => {
7
8
describe ( "transit" , ( ) => {
@@ -42,6 +43,10 @@ describe("transit.ts", () => {
42
43
assert . strictEqual ( result . transition , "width 50ms ease 20ms" ) ;
43
44
} ) ;
44
45
46
+ it ( "should set WebkitTransition" , ( ) => {
47
+ assert . strictEqual ( ( result as any ) . WebkitTransition , "width 50ms ease 20ms" ) ;
48
+ } ) ;
49
+
45
50
it ( "should leave other properties untouched" , ( ) => {
46
51
assert . strictEqual ( result . height , "25px" ) ;
47
52
} ) ;
@@ -70,28 +75,53 @@ describe("transit.ts", () => {
70
75
"width 120ms ease 30ms, background 100ms linear 20ms" ) ;
71
76
} ) ;
72
77
78
+ it ( "should set WebkitTransition" , ( ) => {
79
+ assert . strictEqual ( ( result as any ) . WebkitTransition ,
80
+ "width 120ms ease 30ms, background 100ms linear 20ms" ) ;
81
+ } ) ;
82
+
73
83
it ( "should leave other properties untouched" , ( ) => {
74
84
assert . strictEqual ( result . height , "25px" ) ;
75
85
} ) ;
76
86
} ) ;
77
87
78
- describe ( "when processing style with single transition and vendor prefix " , ( ) => {
88
+ describe ( "when processing style with multiple transition and vendor prefixes " , ( ) => {
79
89
let style : CSSProperties ;
80
90
let result : CSSProperties ;
81
91
82
92
before ( ( ) => {
83
93
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 ) ,
85
98
} ;
86
99
result = resolveTransit ( style ) ;
87
100
} ) ;
88
101
89
102
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
+ } ) ;
91
109
} ) ;
92
110
93
111
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
+ ) ;
95
125
} ) ;
96
126
} ) ;
97
127
0 commit comments