@@ -126,10 +126,10 @@ describe('theming inspection api', () => {
126
126
transpile ( `
127
127
$theme: ${ defineM2Theme ( ) } ;
128
128
div {
129
- content: mat.private-get-theme-version($theme);
129
+ --theme-version: #{ mat.private-get-theme-version($theme)} ;
130
130
}
131
131
` ) ,
132
- ) . toMatch ( / c o n t e n t : 0 ; / ) ;
132
+ ) . toMatch ( '--theme-version : 0;' ) ;
133
133
} ) ;
134
134
} ) ;
135
135
@@ -139,40 +139,40 @@ describe('theming inspection api', () => {
139
139
transpile ( `
140
140
$theme: ${ defineM3Theme ( ) } ;
141
141
div {
142
- content: mat.private-get-theme-version($theme);
142
+ --theme-version: #{ mat.private-get-theme-version($theme)} ;
143
143
}
144
144
` ) ,
145
- ) . toMatch ( / c o n t e n t : 1 ; / ) ;
145
+ ) . toMatch ( '--theme-version : 1;' ) ;
146
146
} ) ;
147
147
148
148
it ( 'should get theme type' , ( ) => {
149
149
expect (
150
150
transpile ( `
151
151
$theme: ${ defineM3Theme ( ) } ;
152
152
div {
153
- content: mat.private-get-theme-type($theme);
153
+ --theme-type: #{ mat.private-get-theme-type($theme)} ;
154
154
}
155
155
` ) ,
156
- ) . toMatch ( / c o n t e n t : l i g h t ; / ) ;
156
+ ) . toMatch ( '--theme-type : light;' ) ;
157
157
} ) ;
158
158
159
159
it ( 'should get role color' , ( ) => {
160
160
expect (
161
161
transpile ( `
162
162
$theme: ${ defineM3Theme ( ) } ;
163
163
div {
164
- content : mat.private-get-theme-color($theme, primary-container);
164
+ color : mat.private-get-theme-color($theme, primary-container);
165
165
}
166
166
` ) ,
167
- ) . toMatch ( / c o n t e n t : # e 0 e 0 f f ; / ) ;
167
+ ) . toMatch ( 'color : #e0e0ff;' ) ;
168
168
} ) ;
169
169
170
170
it ( 'should error on invalid color role' , ( ) => {
171
171
expect ( ( ) =>
172
172
transpile ( `
173
173
$theme: ${ defineM3Theme ( ) } ;
174
174
div {
175
- content : mat.private-get-theme-color($theme, fake-role);
175
+ color : mat.private-get-theme-color($theme, fake-role);
176
176
}
177
177
` ) ,
178
178
) . toThrowError ( / V a l i d c o l o r r o l e s a r e .* G o t : f a k e - r o l e / ) ;
@@ -183,18 +183,18 @@ describe('theming inspection api', () => {
183
183
transpile ( `
184
184
$theme: ${ defineM3Theme ( ) } ;
185
185
div {
186
- content : mat.private-get-theme-color($theme, tertiary, 20);
186
+ color : mat.private-get-theme-color($theme, tertiary, 20);
187
187
}
188
188
` ) ,
189
- ) . toMatch ( / c o n t e n t : # 3 2 3 2 0 0 ; / ) ;
189
+ ) . toMatch ( 'color : #323200;' ) ;
190
190
} ) ;
191
191
192
192
it ( 'should error on invalid color palette' , ( ) => {
193
193
expect ( ( ) =>
194
194
transpile ( `
195
195
$theme: ${ defineM3Theme ( ) } ;
196
196
div {
197
- content : mat.private-get-theme-color($theme, fake-palette, 20);
197
+ color : mat.private-get-theme-color($theme, fake-palette, 20);
198
198
}
199
199
` ) ,
200
200
) . toThrowError ( / V a l i d p a l e t t e s a r e .* G o t : f a k e - p a l e t t e / ) ;
@@ -205,7 +205,7 @@ describe('theming inspection api', () => {
205
205
transpile ( `
206
206
$theme: ${ defineM3Theme ( ) } ;
207
207
div {
208
- content : mat.private-get-theme-color($theme, neutral, 11);
208
+ color : mat.private-get-theme-color($theme, neutral, 11);
209
209
}
210
210
` ) ,
211
211
) . toThrowError ( / V a l i d h u e s f o r n e u t r a l a r e .* G o t : 1 1 / ) ;
@@ -216,10 +216,52 @@ describe('theming inspection api', () => {
216
216
transpile ( `
217
217
$theme: ${ defineM3Theme ( ) } ;
218
218
div {
219
- content : mat.private-get-theme-color($theme);
219
+ color : mat.private-get-theme-color($theme);
220
220
}
221
221
` ) ,
222
222
) . toThrowError ( / E x p e c t e d 2 o r 3 a r g u m e n t s . G o t : 1 / ) ;
223
223
} ) ;
224
+
225
+ it ( 'should get typography properties from theme' , ( ) => {
226
+ const css = transpile ( `
227
+ $theme: ${ defineM3Theme ( ) } ;
228
+ div {
229
+ font: mat.private-get-theme-typography($theme, headline-large);
230
+ font-family: mat.private-get-theme-typography($theme, headline-large, font-family);
231
+ font-size: mat.private-get-theme-typography($theme, headline-large, font-size);
232
+ font-weight: mat.private-get-theme-typography($theme, headline-large, font-weight);
233
+ line-height: mat.private-get-theme-typography($theme, headline-large, line-height);
234
+ letter-spacing: mat.private-get-theme-typography($theme, headline-large, letter-spacing);
235
+ }
236
+ ` ) ;
237
+ expect ( css ) . toMatch ( 'font: 400 2rem / 2.5rem Google Sans;' ) ;
238
+ expect ( css ) . toMatch ( 'font-family: Google Sans;' ) ;
239
+ expect ( css ) . toMatch ( 'font-size: 2rem;' ) ;
240
+ expect ( css ) . toMatch ( 'font-weight: 400;' ) ;
241
+ expect ( css ) . toMatch ( 'line-height: 2.5rem;' ) ;
242
+ expect ( css ) . toMatch ( 'letter-spacing: 0rem;' ) ;
243
+ } ) ;
244
+ } ) ;
245
+
246
+ it ( 'should error on invalid typescale' , ( ) => {
247
+ expect ( ( ) =>
248
+ transpile ( `
249
+ $theme: ${ defineM3Theme ( ) } ;
250
+ div {
251
+ font: mat.private-get-theme-typography($theme, subtitle-large);
252
+ }
253
+ ` ) ,
254
+ ) . toThrowError ( / V a l i d t y p e s c a l e s a r e : .* G o t : s u b t i t l e - l a r g e / ) ;
255
+ } ) ;
256
+
257
+ it ( 'should error on invalid typography property' , ( ) => {
258
+ expect ( ( ) =>
259
+ transpile ( `
260
+ $theme: ${ defineM3Theme ( ) } ;
261
+ div {
262
+ font: mat.private-get-theme-typography($theme, body-small, text-transform);
263
+ }
264
+ ` ) ,
265
+ ) . toThrowError ( / V a l i d t y p o g r a p h y p r o p e r t i e s a r e : .* G o t : t e x t - t r a n s f o r m / ) ;
224
266
} ) ;
225
267
} ) ;
0 commit comments