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 ClrAxis is VERTICAL and there is a BOTTOM ViewportViolation', function(this: TestContext) {
// Test a BOTTOM violataion
const bottomViolation: ClrPopoverPosition = {
axis: ClrAxis.VERTICAL,
side: ClrSide.AFTER,
anchor: ClrAlignment.CENTER,
content: ClrAlignment.CENTER,
};
popoverContent.style.width = '25px';
popoverContent.style.height = window.innerHeight + 'px';
this.positionService.position = bottomViolation;
document.body.appendChild(popoverContent);
this.positionService.alignContent(popoverContent);
expect(handleVerticalAxisOneViolationSpy.calls.count()).toEqual(1);
expect(handleHorizontalAxisOneViolationSpy).not.toHaveBeenCalled();
expect(handleVerticalAxisTwoViolationsSpy).not.toHaveBeenCalled();
expect(handleHorizontalAxisTwoViolationsSpy).not.toHaveBeenCalled();
});
it('and aligns content when ClrAxis is HORIZONTAL and there is a RIGHT ViewportViolation', function(this: TestContext) {
// // Test a right violation
const rightViolation: ClrPopoverPosition = {
axis: ClrAxis.HORIZONTAL,
side: ClrSide.AFTER,
anchor: ClrAlignment.CENTER,
content: ClrAlignment.CENTER,
};
this.positionService.position = rightViolation;
popoverContent.style.width = '25000px';
document.body.appendChild(popoverContent);
this.positionService.alignContent(popoverContent);
expect(handleVerticalAxisOneViolationSpy).not.toHaveBeenCalled();
expect(handleHorizontalAxisOneViolationSpy).toHaveBeenCalled();
expect(handleHorizontalAxisOneViolationSpy.calls.count()).toEqual(1);
expect(handleVerticalAxisTwoViolationsSpy).not.toHaveBeenCalled();
expect(handleHorizontalAxisTwoViolationsSpy).not.toHaveBeenCalled();
});
it('and aligns content when ClrAxis is HORIZONTAL and there is a RIGHT ViewportViolation', function(this: TestContext) {
// // Test a right violation
const rightViolation: ClrPopoverPosition = {
axis: ClrAxis.HORIZONTAL,
side: ClrSide.AFTER,
anchor: ClrAlignment.CENTER,
content: ClrAlignment.CENTER,
};
this.positionService.position = rightViolation;
popoverContent.style.width = '25000px';
document.body.appendChild(popoverContent);
this.positionService.alignContent(popoverContent);
expect(handleVerticalAxisOneViolationSpy).not.toHaveBeenCalled();
expect(handleHorizontalAxisOneViolationSpy).toHaveBeenCalled();
expect(handleHorizontalAxisOneViolationSpy.calls.count()).toEqual(1);
expect(handleVerticalAxisTwoViolationsSpy).not.toHaveBeenCalled();
expect(handleHorizontalAxisTwoViolationsSpy).not.toHaveBeenCalled();
});
it('and aligns content when ClrAxis is HORIZONTAL and there is a RIGHT ViewportViolation', function(this: TestContext) {
// // Test a right violation
const rightViolation: ClrPopoverPosition = {
axis: ClrAxis.HORIZONTAL,
side: ClrSide.AFTER,
anchor: ClrAlignment.CENTER,
content: ClrAlignment.CENTER,
};
this.positionService.position = rightViolation;
popoverContent.style.width = '25000px';
document.body.appendChild(popoverContent);
this.positionService.alignContent(popoverContent);
expect(handleVerticalAxisOneViolationSpy).not.toHaveBeenCalled();
expect(handleHorizontalAxisOneViolationSpy).toHaveBeenCalled();
expect(handleHorizontalAxisOneViolationSpy.calls.count()).toEqual(1);
expect(handleVerticalAxisTwoViolationsSpy).not.toHaveBeenCalled();
expect(handleHorizontalAxisTwoViolationsSpy).not.toHaveBeenCalled();
});
it('and aligns content when ClrAxis is VERTICAL and there is a BOTTOM ViewportViolation', function(this: TestContext) {
// Test a BOTTOM violataion
const bottomViolation: ClrPopoverPosition = {
axis: ClrAxis.VERTICAL,
side: ClrSide.AFTER,
anchor: ClrAlignment.CENTER,
content: ClrAlignment.CENTER,
};
popoverContent.style.width = '25px';
popoverContent.style.height = window.innerHeight + 'px';
this.positionService.position = bottomViolation;
document.body.appendChild(popoverContent);
this.positionService.alignContent(popoverContent);
expect(handleVerticalAxisOneViolationSpy.calls.count()).toEqual(1);
expect(handleHorizontalAxisOneViolationSpy).not.toHaveBeenCalled();
expect(handleVerticalAxisTwoViolationsSpy).not.toHaveBeenCalled();
expect(handleHorizontalAxisTwoViolationsSpy).not.toHaveBeenCalled();
});
it('and aligns content when ClrAxis is VERTICAL and there is a BOTTOM ViewportViolation', function(this: TestContext) {
// Test a BOTTOM violataion
const bottomViolation: ClrPopoverPosition = {
axis: ClrAxis.VERTICAL,
side: ClrSide.AFTER,
anchor: ClrAlignment.CENTER,
content: ClrAlignment.CENTER,
};
popoverContent.style.width = '25px';
popoverContent.style.height = window.innerHeight + 'px';
this.positionService.position = bottomViolation;
document.body.appendChild(popoverContent);
this.positionService.alignContent(popoverContent);
expect(handleVerticalAxisOneViolationSpy.calls.count()).toEqual(1);
expect(handleHorizontalAxisOneViolationSpy).not.toHaveBeenCalled();
expect(handleVerticalAxisTwoViolationsSpy).not.toHaveBeenCalled();
expect(handleHorizontalAxisTwoViolationsSpy).not.toHaveBeenCalled();
});
it('and aligns content when ClrAxis is VERTICAL and there is a BOTTOM ViewportViolation', function(this: TestContext) {
// Test a BOTTOM violataion
const bottomViolation: ClrPopoverPosition = {
axis: ClrAxis.VERTICAL,
side: ClrSide.AFTER,
anchor: ClrAlignment.CENTER,
content: ClrAlignment.CENTER,
};
popoverContent.style.width = '25px';
popoverContent.style.height = window.innerHeight + 'px';
this.positionService.position = bottomViolation;
document.body.appendChild(popoverContent);
this.positionService.alignContent(popoverContent);
expect(handleVerticalAxisOneViolationSpy.calls.count()).toEqual(1);
expect(handleHorizontalAxisOneViolationSpy).not.toHaveBeenCalled();
expect(handleVerticalAxisTwoViolationsSpy).not.toHaveBeenCalled();
expect(handleHorizontalAxisTwoViolationsSpy).not.toHaveBeenCalled();
});
it('and aligns content when ClrAxis is HORIZONTAL and there is a RIGHT ViewportViolation', function(this: TestContext) {
// // Test a right violation
const rightViolation: ClrPopoverPosition = {
axis: ClrAxis.HORIZONTAL,
side: ClrSide.AFTER,
anchor: ClrAlignment.CENTER,
content: ClrAlignment.CENTER,
};
this.positionService.position = rightViolation;
popoverContent.style.width = '25000px';
document.body.appendChild(popoverContent);
this.positionService.alignContent(popoverContent);
expect(handleVerticalAxisOneViolationSpy).not.toHaveBeenCalled();
expect(handleHorizontalAxisOneViolationSpy).toHaveBeenCalled();
expect(handleHorizontalAxisOneViolationSpy.calls.count()).toEqual(1);
expect(handleVerticalAxisTwoViolationsSpy).not.toHaveBeenCalled();
expect(handleHorizontalAxisTwoViolationsSpy).not.toHaveBeenCalled();
});