@@ -6,130 +6,80 @@ describe('transitionToCss', () => {
6
6
const token = getMockToken ( {
7
7
$value : {
8
8
duration : '300ms' ,
9
- timing : [ 0.4 , 0 , 0.2 , 1 ] ,
9
+ timingFunction : [ 0.4 , 0 , 0.2 , 1 ] ,
10
10
} ,
11
11
$type : 'transition' ,
12
12
} )
13
13
14
- expect ( transitionToCss . transform ( token , { } , { } ) ) . toBe ( '300ms cubic-bezier(0.4, 0, 0.2, 1)' )
14
+ expect ( transitionToCss . transform ( token , { } , { } ) ) . toBe ( '300ms cubic-bezier(0.4,0, 0.2,1)' )
15
15
} )
16
16
17
17
it ( 'should transform transition token with delay to CSS' , ( ) => {
18
18
const token = getMockToken ( {
19
19
$value : {
20
20
duration : '300ms' ,
21
- timing : [ 0.4 , 0 , 0.2 , 1 ] ,
21
+ timingFunction : [ 0.4 , 0 , 0.2 , 1 ] ,
22
22
delay : '100ms' ,
23
23
} ,
24
24
$type : 'transition' ,
25
25
} )
26
26
27
- expect ( transitionToCss . transform ( token , { } , { } ) ) . toBe ( '300ms cubic-bezier(0.4, 0, 0.2, 1) 100ms' )
27
+ expect ( transitionToCss . transform ( token , { } , { } ) ) . toBe ( '300ms cubic-bezier(0.4,0, 0.2,1) 100ms' )
28
28
} )
29
29
30
30
it ( 'should transform transition token with resolved references' , ( ) => {
31
31
const token = {
32
32
$value : {
33
33
duration : '300ms' ,
34
- timing : [ 0.4 , 0 , 0.2 , 1 ] ,
34
+ timingFunction : [ 0.4 , 0 , 0.2 , 1 ] ,
35
35
delay : '0ms' ,
36
36
} ,
37
37
$type : 'transition' ,
38
38
}
39
39
const resolvedRefs = {
40
40
duration : '300ms' ,
41
- timing : [ 0.4 , 0 , 0.2 , 1 ] ,
41
+ timingFunction : [ 0.4 , 0 , 0.2 , 1 ] ,
42
42
delay : '0ms' ,
43
43
}
44
44
45
- expect ( transitionToCss . transform ( token , resolvedRefs ) ) . toBe ( '300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms' )
46
- } )
47
-
48
- it ( 'should transform transition token with mixed values and references' , ( ) => {
49
- const token = getMockToken ( {
50
- $value : {
51
- duration : '{motion.duration.base.value}' ,
52
- timing : [ 0.4 , 0 , 0.2 , 1 ] ,
53
- delay : '0ms' ,
54
- } ,
55
- $type : 'transition' ,
56
- } )
57
-
58
- expect ( transitionToCss . transform ( token , resolvedRefs ) ) . toBe ( '300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms' )
59
- } )
60
-
61
- it ( 'should handle common timing function aliases' , ( ) => {
62
- const token = {
63
- $value : {
64
- duration : '300ms' ,
65
- timing : [ 0.4 , 0 , 1 , 1 ] ,
66
- } ,
67
- $type : 'transition' ,
68
- }
69
-
70
- expect ( transitionToCss . transform ( token , { } , { } ) ) . toBe ( '300ms ease-out' )
71
- } )
72
-
73
- it ( 'should handle direct reference token' , ( ) => {
74
- const token = {
75
- $value : '{motion.transition.standard}' ,
76
- $type : 'transition' ,
77
- }
78
- const resolvedRefs = {
79
- 'motion.transition.standard' : {
80
- duration : '300ms' ,
81
- timing : [ 0.4 , 0 , 0.2 , 1 ] ,
82
- delay : '0ms' ,
83
- } ,
84
- }
85
-
86
- expect ( transitionToCss . transform ( token , resolvedRefs ) ) . toBe ( '300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms' )
45
+ expect ( transitionToCss . transform ( token , resolvedRefs ) ) . toBe ( '300ms cubic-bezier(0.4,0,0.2,1) 0ms' )
87
46
} )
88
47
89
48
it ( 'should handle missing optional delay' , ( ) => {
90
- const token = {
49
+ const token = getMockToken ( {
91
50
$value : {
92
51
duration : '300ms' ,
93
- timing : [ 0.4 , 0 , 0.2 , 1 ] ,
52
+ timingFunction : [ 0.4 , 0 , 0.2 , 1 ] ,
94
53
} ,
95
54
$type : 'transition' ,
96
- }
97
-
98
- expect ( transitionToCss . transform ( token , { } , { } ) ) . toBe ( '300ms cubic-bezier(0.4, 0, 0.2, 1)' )
99
- } )
100
-
101
- it ( 'should throw error for invalid token type' , ( ) => {
102
- const token = {
103
- $value : {
104
- duration : '300ms' ,
105
- timing : [ 0.4 , 0 , 0.2 , 1 ] ,
106
- } ,
107
- $type : 'invalid' ,
108
- }
55
+ } )
109
56
110
- expect ( ( ) => transitionToCss . transform ( token , { } , { } ) ) . toThrow ( 'Invalid token type: invalid ')
57
+ expect ( transitionToCss . transform ( token , { } , { } ) ) . toBe ( '300ms cubic-bezier(0.4,0,0.2,1) ')
111
58
} )
112
59
113
60
it ( 'should throw error for missing required properties' , ( ) => {
114
- const token = {
61
+ const token = getMockToken ( {
115
62
$value : {
116
63
duration : '300ms' ,
117
64
} ,
118
65
$type : 'transition' ,
119
- }
120
- // @ts -expect-error: testing invalid token
121
- expect ( ( ) => transitionToCss . transform ( token , { } , { } ) ) . toThrow ( 'Missing required property: timing' )
66
+ } )
67
+ expect ( ( ) => transitionToCss . transform ( token , { } , { } ) ) . toThrow (
68
+ 'Missing property: timingFunction on token with value {"duration":"300ms"}' ,
69
+ )
122
70
} )
123
71
124
72
it ( 'should throw error for invalid timing value' , ( ) => {
125
- const token = {
73
+ const token = getMockToken ( {
126
74
$value : {
127
75
duration : '300ms' ,
128
- timing : [ 0.4 , 0 , 0.2 ] , // Missing one value
76
+ timingFunction : [ 0.4 , 0 , 0.2 ] , // Missing one value
129
77
} ,
130
78
$type : 'transition' ,
131
- }
79
+ } )
132
80
133
- expect ( ( ) => transitionToCss . transform ( token , { } , { } ) ) . toThrow ( 'Invalid timing value' )
81
+ expect ( ( ) => transitionToCss . transform ( token , { } , { } ) ) . toThrow (
82
+ 'Invalid cubicBezier token path, must be an array with 4 numbers, but got this instead: [0.4,0,0.2]' ,
83
+ )
134
84
} )
135
85
} )
0 commit comments