@@ -1553,4 +1553,45 @@ describe('CalendarDayViewComponent component', () => {
1553
1553
. toDate ( )
1554
1554
} ) ;
1555
1555
} ) ;
1556
+
1557
+ it ( 'should allow css variables for colors' , ( ) => {
1558
+ const style = document . createElement ( 'style' ) ;
1559
+ style . setAttribute ( 'type' , 'text/css' ) ;
1560
+ style . innerText = `
1561
+ :root {
1562
+ --white: #fff;
1563
+ --black: #000;
1564
+ }
1565
+ ` ;
1566
+ document . head . appendChild ( style ) ;
1567
+ const fixture : ComponentFixture <
1568
+ CalendarDayViewComponent
1569
+ > = TestBed . createComponent ( CalendarDayViewComponent ) ;
1570
+ fixture . componentInstance . ngOnInit ( ) ;
1571
+ fixture . componentInstance . viewDate = new Date ( '2016-06-01' ) ;
1572
+ fixture . componentInstance . events = [
1573
+ {
1574
+ start : new Date ( '2016-05-30' ) ,
1575
+ end : new Date ( '2016-06-02' ) ,
1576
+ title : 'foo' ,
1577
+ color : {
1578
+ primary : 'var(--white)' ,
1579
+ secondary : 'var(--black)'
1580
+ }
1581
+ }
1582
+ ] ;
1583
+ fixture . componentInstance . ngOnChanges ( { viewDate : { } , events : { } } ) ;
1584
+ fixture . detectChanges ( ) ;
1585
+
1586
+ const computedStyles : CSSStyleDeclaration = window . getComputedStyle (
1587
+ fixture . nativeElement . querySelector ( '.cal-event' )
1588
+ ) ;
1589
+ expect ( computedStyles . getPropertyValue ( 'background-color' ) ) . to . equal (
1590
+ 'rgb(0, 0, 0)'
1591
+ ) ;
1592
+ expect ( computedStyles . getPropertyValue ( 'border-color' ) ) . to . equal (
1593
+ 'rgb(255, 255, 255)'
1594
+ ) ;
1595
+ document . head . appendChild ( style ) ;
1596
+ } ) ;
1556
1597
} ) ;
0 commit comments