Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('and aligns content when visibility is 🆗', function(this: TestContext) {
const goodPosition: ClrPopoverPosition = {
anchor: ClrAlignment.END,
axis: ClrAxis.HORIZONTAL,
content: ClrAlignment.START,
side: ClrSide.AFTER,
};
this.positionService.position = goodPosition;
popoverContent.style.width = '25px';
popoverContent.style.height = '25px';
document.body.appendChild(popoverContent);
this.positionService.alignContent(popoverContent);
expect(handleVerticalAxisOneViolationSpy).not.toHaveBeenCalled();
expect(handleHorizontalAxisOneViolationSpy).not.toHaveBeenCalled();
expect(handleVerticalAxisTwoViolationsSpy).not.toHaveBeenCalled();
expect(handleHorizontalAxisTwoViolationsSpy).not.toHaveBeenCalled();
});
it('and aligns content when visibility is 🆗', function(this: TestContext) {
const goodPosition: ClrPopoverPosition = {
anchor: ClrAlignment.END,
axis: ClrAxis.HORIZONTAL,
content: ClrAlignment.START,
side: ClrSide.AFTER,
};
this.positionService.position = goodPosition;
popoverContent.style.width = '25px';
popoverContent.style.height = '25px';
document.body.appendChild(popoverContent);
this.positionService.alignContent(popoverContent);
expect(handleVerticalAxisOneViolationSpy).not.toHaveBeenCalled();
expect(handleHorizontalAxisOneViolationSpy).not.toHaveBeenCalled();
expect(handleVerticalAxisTwoViolationsSpy).not.toHaveBeenCalled();
expect(handleHorizontalAxisTwoViolationsSpy).not.toHaveBeenCalled();
});
it('and aligns content when Axis is HORIZONTAL and there are BOTTOM/LEFT ViewportViolations', function(this: TestContext) {
const bottomLeftViolation: ClrPopoverPosition = {
axis: ClrAxis.HORIZONTAL,
side: ClrSide.BEFORE,
anchor: ClrAlignment.END,
content: ClrAlignment.START,
};
popoverContent.style.height = window.innerHeight + 'px';
popoverContent.style.width = '25px';
this.positionService.position = bottomLeftViolation;
document.body.appendChild(popoverContent);
this.positionService.alignContent(popoverContent);
expect(handleVerticalAxisOneViolationSpy).not.toHaveBeenCalled();
expect(handleHorizontalAxisOneViolationSpy).not.toHaveBeenCalled();
expect(handleVerticalAxisTwoViolationsSpy).not.toHaveBeenCalled();
expect(handleHorizontalAxisTwoViolationsSpy.calls.count()).toEqual(1);
});
it('and aligns content when Axis is HORIZONTAL and there are TOP/RIGHT ViewportViolations', function(this: TestContext) {
const topRightViolation: ClrPopoverPosition = {
axis: ClrAxis.HORIZONTAL,
side: ClrSide.AFTER,
anchor: ClrAlignment.START,
content: ClrAlignment.END,
};
popoverContent.style.width = window.innerWidth + 'px';
popoverContent.style.height = '25px';
this.positionService.position = topRightViolation;
document.body.appendChild(popoverContent);
this.positionService.alignContent(popoverContent);
expect(handleVerticalAxisOneViolationSpy).not.toHaveBeenCalled();
expect(handleHorizontalAxisOneViolationSpy).not.toHaveBeenCalled();
expect(handleVerticalAxisTwoViolationsSpy).not.toHaveBeenCalled();
expect(handleHorizontalAxisTwoViolationsSpy.calls.count()).toEqual(1);
});
it('and aligns content when Axis is VERTICAL and there are BOTTOM/LEFT ViewportViolations', function(this: TestContext) {
const bottomLeftViolation: ClrPopoverPosition = {
axis: ClrAxis.VERTICAL,
side: ClrSide.AFTER,
anchor: ClrAlignment.START,
content: ClrAlignment.END,
};
popoverContent.style.width = '25px';
popoverContent.style.height = window.innerHeight + 'px';
this.positionService.position = bottomLeftViolation;
document.body.appendChild(popoverContent);
this.positionService.alignContent(popoverContent);
expect(handleVerticalAxisOneViolationSpy).not.toHaveBeenCalled();
expect(handleHorizontalAxisOneViolationSpy).not.toHaveBeenCalled();
expect(handleVerticalAxisTwoViolationsSpy.calls.count()).toEqual(1);
expect(handleHorizontalAxisTwoViolationsSpy).not.toHaveBeenCalled();
});
it('and aligns content when Axis is VERTICAL and there are TOP/RIGHT ViewportViolations', function(this: TestContext) {
const topCenterViolation: ClrPopoverPosition = {
axis: ClrAxis.VERTICAL,
side: ClrSide.BEFORE,
anchor: ClrAlignment.END,
content: ClrAlignment.START,
};
popoverContent.style.width = window.innerWidth + 'px';
popoverContent.style.height = '25px';
this.positionService.position = topCenterViolation;
document.body.appendChild(popoverContent);
this.positionService.alignContent(popoverContent);
expect(handleVerticalAxisOneViolationSpy).not.toHaveBeenCalled();
expect(handleHorizontalAxisOneViolationSpy).not.toHaveBeenCalled();
expect(handleVerticalAxisTwoViolationsSpy.calls.count()).toEqual(1);
expect(handleHorizontalAxisTwoViolationsSpy).not.toHaveBeenCalled();
});
it('and aligns content when Axis is HORIZONTAL and there are BOTTOM/RIGHT ViewportViolations', function(this: TestContext) {
const bottomRightViolation: ClrPopoverPosition = {
axis: ClrAxis.HORIZONTAL,
side: ClrSide.AFTER,
anchor: ClrAlignment.END,
content: ClrAlignment.START,
};
popoverContent.style.height = window.innerHeight + 'px';
popoverContent.style.width = window.innerWidth + 'px';
this.positionService.position = bottomRightViolation;
document.body.appendChild(popoverContent);
this.positionService.alignContent(popoverContent);
expect(handleVerticalAxisOneViolationSpy).not.toHaveBeenCalled();
expect(handleHorizontalAxisOneViolationSpy).not.toHaveBeenCalled();
expect(handleVerticalAxisTwoViolationsSpy).not.toHaveBeenCalled();
expect(handleHorizontalAxisTwoViolationsSpy.calls.count()).toEqual(1);
});
});
it('and aligns content when Axis is VERTICAL and there are BOTTOM/RIGHT ViewportViolations', function(this: TestContext) {
const bottomRightViolation: ClrPopoverPosition = {
axis: ClrAxis.VERTICAL,
side: ClrSide.AFTER,
anchor: ClrAlignment.END,
content: ClrAlignment.START,
};
popoverContent.style.width = window.innerWidth + 'px';
popoverContent.style.height = window.innerHeight + 'px';
this.positionService.position = bottomRightViolation;
document.body.appendChild(popoverContent);
this.positionService.alignContent(popoverContent);
expect(handleVerticalAxisOneViolationSpy).not.toHaveBeenCalled();
expect(handleHorizontalAxisOneViolationSpy).not.toHaveBeenCalled();
expect(handleVerticalAxisTwoViolationsSpy.calls.count()).toEqual(1);
expect(handleHorizontalAxisTwoViolationsSpy).not.toHaveBeenCalled();
});