@@ -323,4 +323,57 @@ describe('CalendarDayViewComponent component', () => {
323
323
} ) ;
324
324
} ) ;
325
325
326
+ it ( 'should show a tooltip on mouseover of the event' , ( ) => {
327
+
328
+ const fixture : ComponentFixture < CalendarDayViewComponent > = TestBed . createComponent ( CalendarDayViewComponent ) ;
329
+ eventTitle . dayTooltip = ( event : CalendarEvent ) => {
330
+ return `title: ${ event . title } ` ;
331
+ } ;
332
+ fixture . componentInstance . viewDate = new Date ( '2016-06-01' ) ;
333
+ fixture . componentInstance . events = [ {
334
+ start : new Date ( '2016-05-30' ) ,
335
+ end : new Date ( '2016-06-02' ) ,
336
+ title : 'foo <b>bar</b>' ,
337
+ color : {
338
+ primary : 'blue' ,
339
+ secondary : ''
340
+ }
341
+ } ] ;
342
+ fixture . componentInstance . ngOnChanges ( { viewDate : { } , events : { } } ) ;
343
+ fixture . detectChanges ( ) ;
344
+ const event : HTMLElement = fixture . nativeElement . querySelector ( '.cal-event' ) ;
345
+ triggerDomEvent ( 'mouseenter' , event ) ;
346
+ fixture . detectChanges ( ) ;
347
+ const tooltip : Element = document . body . querySelector ( '.cal-tooltip' ) ;
348
+ expect ( tooltip . querySelector ( '.cal-tooltip-inner' ) . innerHTML ) . to . equal ( 'title: foo <b>bar</b>' ) ;
349
+ expect ( tooltip . classList . contains ( 'cal-tooltip-top' ) ) . to . be . true ;
350
+ triggerDomEvent ( 'mouseleave' , event ) ;
351
+ fixture . detectChanges ( ) ;
352
+ expect ( document . body . querySelector ( '.cal-tooltip' ) ) . not . to . be . ok ;
353
+
354
+ } ) ;
355
+
356
+ it ( 'should disable the tooltip' , ( ) => {
357
+
358
+ const fixture : ComponentFixture < CalendarDayViewComponent > = TestBed . createComponent ( CalendarDayViewComponent ) ;
359
+ eventTitle . dayTooltip = ( ) => '' ;
360
+ fixture . componentInstance . viewDate = new Date ( '2016-06-01' ) ;
361
+ fixture . componentInstance . events = [ {
362
+ start : new Date ( '2016-05-30' ) ,
363
+ end : new Date ( '2016-06-02' ) ,
364
+ title : 'foo <b>bar</b>' ,
365
+ color : {
366
+ primary : 'blue' ,
367
+ secondary : ''
368
+ }
369
+ } ] ;
370
+ fixture . componentInstance . ngOnChanges ( { viewDate : { } , events : { } } ) ;
371
+ fixture . detectChanges ( ) ;
372
+ const event : HTMLElement = fixture . nativeElement . querySelector ( '.cal-event' ) ;
373
+ triggerDomEvent ( 'mouseenter' , event ) ;
374
+ fixture . detectChanges ( ) ;
375
+ expect ( document . body . querySelector ( '.cal-tooltip' ) ) . not . to . be . ok ;
376
+
377
+ } ) ;
378
+
326
379
} ) ;
0 commit comments