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();
});
it('and aligns content when ClrAxis is HORIZONTAL and there is LEFT ViewportViolation', function(this: TestContext) {
const leftViolation: ClrPopoverPosition = {
axis: ClrAxis.HORIZONTAL,
side: ClrSide.BEFORE,
anchor: ClrAlignment.START,
content: ClrAlignment.START,
};
// Test a LEFT violation
this.positionService.position = leftViolation;
popoverContent.style.width = '25px';
popoverContent.style.height = '25px';
document.body.appendChild(popoverContent);
this.positionService.alignContent(popoverContent);
expect(handleVerticalAxisOneViolationSpy).not.toHaveBeenCalled();
expect(handleHorizontalAxisOneViolationSpy.calls.count()).toEqual(1);
expect(handleVerticalAxisTwoViolationsSpy).not.toHaveBeenCalled();
expect(handleHorizontalAxisTwoViolationsSpy).not.toHaveBeenCalled();
});
import { InlineAlertComponent } from "../../../shared/inline-alert/inline-alert.component";
import { MessageHandlerService } from "../../../shared/message-handler/message-handler.service";
@Component({
selector: "new-scanner-modal",
templateUrl: "new-scanner-modal.component.html",
styleUrls: ['../../../common.scss']
})
export class NewScannerModalComponent {
testMap: any = {};
opened: boolean = false;
@Output() notify = new EventEmitter();
@ViewChild(NewScannerFormComponent, {static: true})
newScannerFormComponent: NewScannerFormComponent;
checkBtnState: ClrLoadingState = ClrLoadingState.DEFAULT;
saveBtnState: ClrLoadingState = ClrLoadingState.DEFAULT;
onTesting: boolean = false;
onSaving: boolean = false;
isEdit: boolean = false;
originValue: any;
uid: string;
editScanner: Scanner;
@ViewChild(InlineAlertComponent, { static: false }) inlineAlert: InlineAlertComponent;
constructor(
private configScannerService: ConfigScannerService,
private msgHandler: MessageHandlerService
) {}
open(): void {
// reset
this.opened = true;
this.inlineAlert.close();
this.testMap = {};