@@ -357,7 +357,7 @@ registerSuite('ThemedMixin', {
357
357
variants : {
358
358
'theme variant can be injected via a registry' ( ) {
359
359
const themeWithVariant = {
360
- css : {
360
+ theme : {
361
361
'test-key' : {
362
362
root : 'themed-root'
363
363
}
@@ -387,7 +387,7 @@ registerSuite('ThemedMixin', {
387
387
} ;
388
388
389
389
const themeWithVariant = {
390
- css : {
390
+ theme : {
391
391
'test-key' : {
392
392
root : 'variant-themed-root'
393
393
}
@@ -413,9 +413,71 @@ registerSuite('ThemedMixin', {
413
413
renderResult = themedInstance . __render__ ( ) as VNode ;
414
414
assert . deepEqual ( renderResult . properties . classes , 'variant-root' ) ;
415
415
} ,
416
+ 'should use default theme when set via theme context' ( ) {
417
+ const themeWithVariants = {
418
+ theme : {
419
+ 'test-key' : {
420
+ root : 'variant-themed-root'
421
+ }
422
+ } ,
423
+ variants : {
424
+ default : {
425
+ root : 'variant-root'
426
+ } ,
427
+ red : {
428
+ root : 'red-root'
429
+ }
430
+ }
431
+ } ;
432
+
433
+ registerThemeInjector ( themeWithVariants , testRegistry ) ;
434
+ class InjectedTheme extends TestWidget {
435
+ render ( ) {
436
+ return v ( 'div' , { classes : this . variant ( ) } ) ;
437
+ }
438
+ }
439
+ const themedInstance = new InjectedTheme ( ) ;
440
+ themedInstance . registry . base = testRegistry ;
441
+ themedInstance . __setProperties__ ( { } ) ;
442
+ let renderResult = themedInstance . __render__ ( ) as VNode ;
443
+ assert . deepEqual ( renderResult . properties . classes , 'variant-root' ) ;
444
+ } ,
445
+ 'should use be able to choose variant via theme context' ( ) {
446
+ const themeWithVariants = {
447
+ theme : {
448
+ 'test-key' : {
449
+ root : 'variant-themed-root'
450
+ }
451
+ } ,
452
+ variants : {
453
+ default : {
454
+ root : 'variant-root'
455
+ } ,
456
+ red : {
457
+ root : 'red-root'
458
+ }
459
+ }
460
+ } ;
461
+
462
+ const themeInjectorContext = registerThemeInjector ( themeWithVariants , testRegistry ) ;
463
+ class InjectedTheme extends TestWidget {
464
+ render ( ) {
465
+ return v ( 'div' , { classes : this . variant ( ) } ) ;
466
+ }
467
+ }
468
+ const themedInstance = new InjectedTheme ( ) ;
469
+ themedInstance . registry . base = testRegistry ;
470
+ themedInstance . __setProperties__ ( { } ) ;
471
+ let renderResult = themedInstance . __render__ ( ) as VNode ;
472
+ assert . deepEqual ( renderResult . properties . classes , 'variant-root' ) ;
473
+ themeInjectorContext . set ( themeWithVariants , 'red' ) ;
474
+ themedInstance . __setProperties__ ( { } ) ;
475
+ renderResult = themedInstance . __render__ ( ) as VNode ;
476
+ assert . deepEqual ( renderResult . properties . classes , 'red-root' ) ;
477
+ } ,
416
478
'theme variant can be set at the widget level' ( ) {
417
479
const themeWithVariant = {
418
- css : {
480
+ theme : {
419
481
'test-key' : {
420
482
root : 'themed-root'
421
483
}
@@ -440,7 +502,7 @@ registerSuite('ThemedMixin', {
440
502
} ,
441
503
'theme property overrides injected property' ( ) {
442
504
const themeWithVariant = {
443
- css : {
505
+ theme : {
444
506
'test-key' : {
445
507
root : 'themed-root'
446
508
}
@@ -451,7 +513,7 @@ registerSuite('ThemedMixin', {
451
513
} ;
452
514
453
515
const secondThemeWithVariant = {
454
- css : {
516
+ theme : {
455
517
'test-key' : {
456
518
root : 'themed-root'
457
519
}
@@ -478,8 +540,8 @@ registerSuite('ThemedMixin', {
478
540
} ,
479
541
'can inject theme config with variants' ( ) {
480
542
const themeWithVariantConfig = {
481
- css : {
482
- css : {
543
+ theme : {
544
+ theme : {
483
545
'test-key' : {
484
546
root : 'themed-root'
485
547
}
0 commit comments