`
);
const directive = fixture.debugElement.query(
By.directive(PopoverDirective)
);
dispatchMouseEvent(directive.nativeElement, 'click');
fixture.detectChanges();
const windowEl = getWindow(fixture.nativeElement);
expect(windowEl).toHaveCssClass('popover');
expect(windowEl).toHaveCssClass('popover-left');
expect(windowEl.textContent.trim()).toBe('Great tip!');
});
it('should properly position popovers when a component is using the OnPush strategy', () => {
const fixture = createOnPushTestComponent(
`
`
);
const context = fixture.componentInstance;
context.cdRef.markForCheck();
const directive = fixture.debugElement.query(
By.directive(PopoverDirective)
);
dispatchMouseEvent(directive.nativeElement, 'click');
fixture.detectChanges();
const windowEl = getWindow(fixture.nativeElement);
context.cdRef.markForCheck();
expect(windowEl).toHaveCssClass('popover');
expect(windowEl).toHaveCssClass('popover-left');
expect(windowEl.textContent.trim()).toBe('Great tip!');
});
it('should set position to top when use auto position and fit on screen', () => {
const fixture = createTestComponent(
`
`
);
const directive = fixture.debugElement.query(
By.directive(PopoverDirective)
);
dispatchMouseEvent(directive.nativeElement, 'click');
fixture.detectChanges();
const windowEl = getWindow(fixture.nativeElement);
expect(windowEl).toHaveCssClass('popover');
expect(windowEl).toHaveCssClass('popover-auto');
expect(windowEl).toHaveCssClass('right');
expect(windowEl.textContent.trim()).toBe('Great tip!');
});
it('should set position to bottom when use auto position', () => {
const fixture = createTestComponent(
`
`
);
const directive = fixture.debugElement.query(
By.directive(PopoverDirective)
);
dispatchMouseEvent(directive.nativeElement, 'click');
fixture.detectChanges();
const windowEl = getWindow(fixture.nativeElement);
expect(windowEl).toHaveCssClass('popover');
expect(windowEl).toHaveCssClass('popover-auto');
expect(windowEl).toHaveCssClass('bottom');
expect(windowEl.textContent.trim()).toBe('Great tip!');
});
it('should set position to top when use auto position and fit on screen', () => {
const fixture = createTestComponent(
`
`
);
const directive = fixture.debugElement.query(
By.directive(PopoverDirective)
);
dispatchMouseEvent(directive.nativeElement, 'click');
fixture.detectChanges();
const windowEl = getWindow(fixture.nativeElement);
expect(windowEl).toHaveCssClass('popover');
expect(windowEl).toHaveCssClass('popover-auto');
expect(windowEl).toHaveCssClass('top');
expect(windowEl.textContent.trim()).toBe('Great tip!');
});
it('should set position to right when use auto position and fit on screen', () => {
const fixture = createTestComponent(
`
`
);
const directive = fixture.debugElement.query(
By.directive(PopoverDirective)
);
dispatchMouseEvent(directive.nativeElement, 'click');
fixture.detectChanges();
const windowEl = getWindow(fixture.nativeElement);
expect(windowEl).toHaveCssClass('popover');
expect(windowEl).toHaveCssClass('popover-auto');
expect(windowEl).toHaveCssClass('right');
expect(windowEl.textContent.trim()).toBe('Great tip!');
});
it('should set position to left when use auto position and fit on screen', () => {
const fixture = createTestComponent(
`