Skip to content

Commit

Permalink
test(tooltip): add 'tooltipClass' change test
Browse files Browse the repository at this point in the history
  • Loading branch information
maxokorokov committed Oct 21, 2019
1 parent 48bdf62 commit 72f1206
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/tooltip/tooltip.spec.ts
Expand Up @@ -5,7 +5,6 @@ import {By} from '@angular/platform-browser';
import {
AfterViewInit,
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
TemplateRef,
ViewChild,
Expand Down Expand Up @@ -165,6 +164,21 @@ describe('ngb-tooltip', () => {
expect(directive.nativeElement.getAttribute('aria-describedby')).toBeNull();
});

it('should propagate tooltipClass changes to the window', () => {
const fixture = createTestComponent(`<div ngbTooltip="Great tip!" [tooltipClass]="tooltipClass"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbTooltip));

triggerEvent(directive, 'mouseenter');
fixture.detectChanges();
const windowEl = getWindow(fixture.nativeElement);
expect(windowEl).toHaveCssClass('my-tooltip-class');

fixture.componentInstance.tooltipClass = 'my-tooltip-class-2';
fixture.detectChanges();
expect(windowEl).not.toHaveCssClass('my-tooltip-class');
expect(windowEl).toHaveCssClass('my-tooltip-class-2');
});

it('should not open a tooltip if content is falsy', () => {
const fixture = createTestComponent(`<div [ngbTooltip]="notExisting"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbTooltip));
Expand Down Expand Up @@ -638,6 +652,7 @@ describe('ngb-tooltip', () => {
export class TestComponent {
name = 'World';
show = true;
tooltipClass = 'my-tooltip-class';

@ViewChild(NgbTooltip, {static: true}) tooltip: NgbTooltip;

Expand Down

0 comments on commit 72f1206

Please sign in to comment.