@@ -185,95 +185,147 @@ describe('M3 theme', () => {
185
185
expect ( css ) . toContain ( '--mdc-checkbox-selected-checkmark-color: magenta' ) ;
186
186
expect ( css ) . toContain ( '--mdc-checkbox-selected-checkmark-color: cyan' ) ;
187
187
} ) ;
188
- } ) ;
189
-
190
- it ( 'should error if used on M2 theme' , ( ) => {
191
- expect ( ( ) =>
192
- transpile ( `
193
- @use '../../tokens/token-utils';
194
188
195
- $theme: mat.m2-define-light-theme(mat.$m2-red-palette, mat.$m2-red-palette);
196
-
197
- $theme: token-utils.extend-theme($theme, ((mdc, checkbox), (mat, checkbox)), (
198
- selected-checkmark-color: magenta
199
- ));
189
+ it ( 'should error if used on M2 theme' , ( ) => {
190
+ expect ( ( ) =>
191
+ transpile ( `
192
+ @use '../../tokens/token-utils';
200
193
201
- html {
202
- @include mat.checkbox-theme($theme);
203
- }
204
- ` ) ,
205
- ) . toThrowError ( / T h e ` e x t e n d - t h e m e ` f u n c t i o n s a r e o n l y s u p p o r t e d f o r M 3 t h e m e s / ) ;
206
- } ) ;
207
-
208
- it ( 'should error on invalid namespace' , ( ) => {
209
- expect ( ( ) =>
210
- transpile ( `
211
- @use '../../tokens/token-utils';
194
+ $theme: mat.m2-define-light-theme(mat.$m2-red-palette, mat.$m2-red-palette);
212
195
213
- $theme: token-utils.extend-theme($theme, ((mdc, checkbox), (mat, checkbocks)), (
214
- selected-checkmark-color: magenta
215
- ));
216
-
217
- html {
218
- @include mat.checkbox-theme($theme);
219
- }
220
- ` ) ,
221
- ) . toThrowError (
222
- / E r r o r e x t e n d i n g t h e m e : T h e m e d o e s n o t h a v e t o k e s f o r n a m e s p a c e ` \( m a t , c h e c k b o c k s \) ` / ,
223
- ) ;
224
- } ) ;
196
+ $theme: token-utils.extend-theme($theme, ((mdc, checkbox), (mat, checkbox)), (
197
+ selected-checkmark-color: magenta
198
+ ));
225
199
226
- it ( 'should error on ambiguous shorthand token name' , ( ) => {
227
- expect ( ( ) =>
228
- transpile ( `
229
- @use '../../tokens/token-utils';
200
+ html {
201
+ @include mat.checkbox-theme($theme);
202
+ }
203
+ ` ) ,
204
+ ) . toThrowError ( / T h e ` e x t e n d - t h e m e ` f u n c t i o n s a r e o n l y s u p p o r t e d f o r M 3 t h e m e s / ) ;
205
+ } ) ;
230
206
231
- $theme: token-utils.extend-theme($theme, ((mdc, checkbox), (mdc, radio)), (
232
- selected-checkmark-color: magenta
233
- ));
207
+ it ( 'should error on invalid namespace' , ( ) => {
208
+ expect ( ( ) =>
209
+ transpile ( `
210
+ @use '../../tokens/token-utils';
234
211
235
- html {
236
- @include mat.checkbox-theme($theme);
237
- }
238
- ` ) ,
239
- ) . toThrowError (
240
- / E r r o r e x t e n d i n g t h e m e : A m b i g u o u s t o k e n n a m e ` .* ` e x i s t s i n m u l t i p l e n a m e s p a c e s : ` \( m d c , c h e c k b o x \) ` a n d ` \( m d c , r a d i o \) ` / ,
241
- ) ;
242
- } ) ;
212
+ $theme: token-utils.extend-theme($theme, ((mdc, checkbox), (mat, checkbocks)), (
213
+ selected-checkmark-color: magenta
214
+ ));
215
+
216
+ html {
217
+ @include mat.checkbox-theme($theme);
218
+ }
219
+ ` ) ,
220
+ ) . toThrowError (
221
+ / E r r o r e x t e n d i n g t h e m e : T h e m e d o e s n o t h a v e t o k e n s f o r n a m e s p a c e ` \( m a t , c h e c k b o c k s \) ` / ,
222
+ ) ;
223
+ } ) ;
243
224
244
- it ( 'should error on unknown variant ' , ( ) => {
245
- expect ( ( ) =>
246
- transpile ( `
247
- @use '../../tokens/token-utils';
225
+ it ( 'should error on ambiguous shorthand token name ' , ( ) => {
226
+ expect ( ( ) =>
227
+ transpile ( `
228
+ @use '../../tokens/token-utils';
248
229
249
- $theme: token-utils.extend-theme($theme, ((mdc, checkbox), (mat, checkbox)), (
250
- accent: (
230
+ $theme: token-utils.extend-theme($theme, ((mdc, checkbox), (mdc, radio)), (
251
231
selected-checkmark-color: magenta
252
- )
253
- ));
254
-
255
- html {
256
- @include mat.checkbox-theme($theme);
257
- }
258
- ` ) ,
259
- ) . toThrowError (
260
- / E r r o r e x t e n d i n g t h e m e : U n r e c o g n i z e d c o l o r v a r i a n t ` a c c e n t ` . A l l o w e d v a r i a n t s a r e : p r i m a r y , s e c o n d a r y , t e r t i a r y , e r r o r , s u r f a c e / ,
261
- ) ;
262
- } ) ;
232
+ ));
233
+
234
+ html {
235
+ @include mat.checkbox-theme($theme);
236
+ }
237
+ ` ) ,
238
+ ) . toThrowError (
239
+ / E r r o r e x t e n d i n g t h e m e : A m b i g u o u s t o k e n n a m e ` .* ` e x i s t s i n m u l t i p l e n a m e s p a c e s : ` \( m d c , c h e c k b o x \) ` a n d ` \( m d c , r a d i o \) ` / ,
240
+ ) ;
241
+ } ) ;
263
242
264
- it ( 'should error on unknown token' , ( ) => {
265
- expect ( ( ) =>
266
- transpile ( `
267
- @use '../../tokens/token-utils';
243
+ it ( 'should error on unknown variant' , ( ) => {
244
+ expect ( ( ) =>
245
+ transpile ( `
246
+ @use '../../tokens/token-utils';
247
+
248
+ $theme: token-utils.extend-theme($theme, ((mdc, checkbox), (mat, checkbox)), (
249
+ accent: (
250
+ selected-checkmark-color: magenta
251
+ )
252
+ ));
253
+
254
+ html {
255
+ @include mat.checkbox-theme($theme);
256
+ }
257
+ ` ) ,
258
+ ) . toThrowError (
259
+ / E r r o r e x t e n d i n g t h e m e : U n r e c o g n i z e d c o l o r v a r i a n t ` a c c e n t ` . A l l o w e d v a r i a n t s a r e : p r i m a r y , s e c o n d a r y , t e r t i a r y , e r r o r , s u r f a c e / ,
260
+ ) ;
261
+ } ) ;
268
262
269
- $theme: token-utils.extend-theme($theme, ((mdc, checkbox), (mat, checkbox)), (
270
- fake-token: red
271
- ));
263
+ it ( 'should error on unknown token' , ( ) => {
264
+ expect ( ( ) =>
265
+ transpile ( `
266
+ @use '../../tokens/token-utils';
267
+
268
+ $theme: token-utils.extend-theme($theme, ((mdc, checkbox), (mat, checkbox)), (
269
+ fake-token: red
270
+ ));
271
+
272
+ html {
273
+ @include mat.checkbox-theme($theme);
274
+ }
275
+ ` ) ,
276
+ ) . toThrowError (
277
+ / E r r o r e x t e n d i n g t h e m e : U n r e c o g n i z e d t o k e n ` f a k e - t o k e n ` . A l l o w e d t o k e n s a r e : / ,
278
+ ) ;
279
+ } ) ;
272
280
273
- html {
274
- @include mat.checkbox-theme($theme);
275
- }
276
- ` ) ,
277
- ) . toThrowError ( / E r r o r e x t e n d i n g t h e m e : U n r e c o g n i z e d t o k e n ` f a k e - t o k e n ` . A l l o w e d t o k e n s a r e : / ) ;
281
+ it ( 'should not error when calling component extend-theme functions' , ( ) => {
282
+ // Ensures that no components have issues with ambiguous token names.
283
+ expect ( ( ) =>
284
+ transpile ( `
285
+ $theme: mat.core-extend-theme($theme, ());
286
+ $theme: mat.ripple-extend-theme($theme, ());
287
+ $theme: mat.option-extend-theme($theme, ());
288
+ $theme: mat.optgroup-extend-theme($theme, ());
289
+ $theme: mat.pseudo-checkbox-extend-theme($theme, ());
290
+ $theme: mat.autocomplete-extend-theme($theme, ());
291
+ $theme: mat.badge-extend-theme($theme, ());
292
+ $theme: mat.bottom-sheet-extend-theme($theme, ());
293
+ $theme: mat.button-extend-theme($theme, ());
294
+ $theme: mat.fab-extend-theme($theme, ());
295
+ $theme: mat.icon-button-extend-theme($theme, ());
296
+ $theme: mat.button-toggle-extend-theme($theme, ());
297
+ $theme: mat.card-extend-theme($theme, ());
298
+ $theme: mat.checkbox-extend-theme($theme, ());
299
+ $theme: mat.chips-extend-theme($theme, ());
300
+ $theme: mat.datepicker-extend-theme($theme, ());
301
+ $theme: mat.dialog-extend-theme($theme, ());
302
+ $theme: mat.divider-extend-theme($theme, ());
303
+ $theme: mat.expansion-extend-theme($theme, ());
304
+ $theme: mat.form-field-extend-theme($theme, ());
305
+ $theme: mat.grid-list-extend-theme($theme, ());
306
+ $theme: mat.icon-extend-theme($theme, ());
307
+ $theme: mat.list-extend-theme($theme, ());
308
+ $theme: mat.menu-extend-theme($theme, ());
309
+ $theme: mat.paginator-extend-theme($theme, ());
310
+ $theme: mat.progress-bar-extend-theme($theme, ());
311
+ $theme: mat.progress-spinner-extend-theme($theme, ());
312
+ $theme: mat.radio-extend-theme($theme, ());
313
+ $theme: mat.select-extend-theme($theme, ());
314
+ $theme: mat.sidenav-extend-theme($theme, ());
315
+ $theme: mat.slide-toggle-extend-theme($theme, ());
316
+ $theme: mat.slider-extend-theme($theme, ());
317
+ $theme: mat.snack-bar-extend-theme($theme, ());
318
+ $theme: mat.sort-extend-theme($theme, ());
319
+ $theme: mat.stepper-extend-theme($theme, ());
320
+ $theme: mat.table-extend-theme($theme, ());
321
+ $theme: mat.tabs-extend-theme($theme, ());
322
+ $theme: mat.toolbar-extend-theme($theme, ());
323
+ $theme: mat.tooltip-extend-theme($theme, ());
324
+ $theme: mat.tree-extend-theme($theme, ());
325
+
326
+ @include mat.all-component-themes($theme);
327
+ ` ) ,
328
+ ) . not . toThrow ( ) ;
329
+ } ) ;
278
330
} ) ;
279
331
} ) ;
0 commit comments