8
8
*/
9
9
10
10
describe ( 'Stylex plugin utils' , ( ) => {
11
- let getStyleXValues ;
11
+ let getStyleXData ;
12
12
let styleElements ;
13
13
14
14
function defineStyles ( style ) {
@@ -22,7 +22,7 @@ describe('Stylex plugin utils', () => {
22
22
}
23
23
24
24
beforeEach ( ( ) => {
25
- getStyleXValues = require ( '../utils' ) . getStyleXValues ;
25
+ getStyleXData = require ( '../utils' ) . getStyleXData ;
26
26
27
27
styleElements = [ ] ;
28
28
} ) ;
@@ -47,16 +47,25 @@ describe('Stylex plugin utils', () => {
47
47
` ) ;
48
48
49
49
expect (
50
- getStyleXValues ( {
50
+ getStyleXData ( {
51
+ // The source/module styles are defined in
52
+ Example__style : 'Example__style' ,
53
+
54
+ // Map of CSS style to StyleX class name, booleans, or nested structures
51
55
display : 'foo' ,
52
56
flexDirection : 'baz' ,
53
57
alignItems : 'bar' ,
54
58
} ) ,
55
59
) . toMatchInlineSnapshot ( `
56
60
Object {
57
- "alignItems": "center",
58
- "display": "flex",
59
- "flexDirection": "center",
61
+ "resolvedStyles": Object {
62
+ "alignItems": "center",
63
+ "display": "flex",
64
+ "flexDirection": "center",
65
+ },
66
+ "sources": Array [
67
+ "Example__style",
68
+ ],
60
69
}
61
70
` ) ;
62
71
} ) ;
@@ -75,15 +84,25 @@ describe('Stylex plugin utils', () => {
75
84
` ) ;
76
85
77
86
expect (
78
- getStyleXValues ( [
79
- { display : 'foo' } ,
80
- { flexDirection : 'baz' , alignItems : 'bar' } ,
87
+ getStyleXData ( [
88
+ { Example1__style : 'Example1__style' , display : 'foo' } ,
89
+ {
90
+ Example2__style : 'Example2__style' ,
91
+ flexDirection : 'baz' ,
92
+ alignItems : 'bar' ,
93
+ } ,
81
94
] ) ,
82
95
) . toMatchInlineSnapshot ( `
83
96
Object {
84
- "alignItems": "center",
85
- "display": "flex",
86
- "flexDirection": "center",
97
+ "resolvedStyles": Object {
98
+ "alignItems": "center",
99
+ "display": "flex",
100
+ "flexDirection": "center",
101
+ },
102
+ "sources": Array [
103
+ "Example1__style",
104
+ "Example2__style",
105
+ ],
87
106
}
88
107
` ) ;
89
108
} ) ;
@@ -102,19 +121,29 @@ describe('Stylex plugin utils', () => {
102
121
` ) ;
103
122
104
123
expect (
105
- getStyleXValues ( [
124
+ getStyleXData ( [
106
125
false ,
107
- { display : 'foo' } ,
126
+ { Example1__style : 'Example1__style' , display : 'foo' } ,
108
127
false ,
109
128
false ,
110
- { flexDirection : 'baz' , alignItems : 'bar' } ,
129
+ {
130
+ Example2__style : 'Example2__style' ,
131
+ flexDirection : 'baz' ,
132
+ alignItems : 'bar' ,
133
+ } ,
111
134
false ,
112
135
] ) ,
113
136
) . toMatchInlineSnapshot ( `
114
137
Object {
115
- "alignItems": "center",
116
- "display": "flex",
117
- "flexDirection": "center",
138
+ "resolvedStyles": Object {
139
+ "alignItems": "center",
140
+ "display": "flex",
141
+ "flexDirection": "center",
142
+ },
143
+ "sources": Array [
144
+ "Example1__style",
145
+ "Example2__style",
146
+ ],
118
147
}
119
148
` ) ;
120
149
} ) ;
@@ -133,7 +162,11 @@ describe('Stylex plugin utils', () => {
133
162
` ) ;
134
163
135
164
expect (
136
- getStyleXValues ( {
165
+ getStyleXData ( {
166
+ // The source/module styles are defined in
167
+ Example__style : 'Example__style' ,
168
+
169
+ // Map of CSS style to StyleX class name, booleans, or nested structures
137
170
color : 'foo' ,
138
171
':hover' : {
139
172
color : 'bar' ,
@@ -142,11 +175,16 @@ describe('Stylex plugin utils', () => {
142
175
} ) ,
143
176
) . toMatchInlineSnapshot ( `
144
177
Object {
145
- ":hover": Object {
146
- "color": "blue",
147
- "textDecoration": "none",
178
+ "resolvedStyles": Object {
179
+ ":hover": Object {
180
+ "color": "blue",
181
+ "textDecoration": "none",
182
+ },
183
+ "color": "black",
148
184
},
149
- "color": "black",
185
+ "sources": Array [
186
+ "Example__style",
187
+ ],
150
188
}
151
189
` ) ;
152
190
} ) ;
@@ -165,17 +203,28 @@ describe('Stylex plugin utils', () => {
165
203
` ) ;
166
204
167
205
expect (
168
- getStyleXValues ( [
169
- { display : 'foo' } ,
206
+ getStyleXData ( [
207
+ { Example1__style : 'Example1__style' , display : 'foo' } ,
170
208
false ,
171
- [ false , { flexDirection : 'baz' } , { alignItems : 'bar' } ] ,
209
+ [
210
+ false ,
211
+ { Example2__style : 'Example2__style' , flexDirection : 'baz' } ,
212
+ { Example3__style : 'Example3__style' , alignItems : 'bar' } ,
213
+ ] ,
172
214
false ,
173
215
] ) ,
174
216
) . toMatchInlineSnapshot ( `
175
217
Object {
176
- "alignItems": "center",
177
- "display": "flex",
178
- "flexDirection": "center",
218
+ "resolvedStyles": Object {
219
+ "alignItems": "center",
220
+ "display": "flex",
221
+ "flexDirection": "center",
222
+ },
223
+ "sources": Array [
224
+ "Example1__style",
225
+ "Example2__style",
226
+ "Example3__style",
227
+ ],
179
228
}
180
229
` ) ;
181
230
} ) ;
0 commit comments