Summary Table
Categories |
Total Count |
PII |
0 |
URL |
0 |
DNS |
0 |
EKL |
0 |
IP |
0 |
PORT |
0 |
VsID |
0 |
CF |
0 |
AI |
0 |
VPD |
0 |
PL |
0 |
Other |
0 |
File Content
import { ModalComponent } from './modal.component';
import { ElementRef } from '@angular/core';
describe('ModalComponent', () => {
let component: ModalComponent;
beforeEach(() => {
component = new ModalComponent();
jasmine.clock().install();
});
afterEach(function() {
jasmine.clock().uninstall();
});
it('should be created', () => {
expect(component).toBeTruthy();
});
it('test ngOnInit method', () => {
expect(component.closeButton).not.toEqual(undefined);
expect(component.closeButton).not.toEqual(null);
expect(component.modalTitle).toEqual(null);
expect(component.hidden).toEqual(true);
expect(component.modalClosed).not.toEqual(undefined);
expect(component.modalClosed).not.toEqual(null);
expect(component.modal).toEqual('this is the modal string');
component.ngOnInit();
// Verify that nothing changed.
expect(component.closeButton).not.toEqual(undefined);
expect(component.closeButton).not.toEqual(null);
expect(component.modalTitle).toEqual(null);
expect(component.hidden).toEqual(true);
expect(component.modalClosed).not.toEqual(undefined);
expect(component.modalClosed).not.toEqual(null);
expect(component.modal).toEqual('this is the modal string');
});
it('test ngOnChanges method', () => {
component.closeButton = <ElementRef> {
nativeElement: {
focus: () => true
}
}
spyOn(component.closeButton.nativeElement, 'focus');
let changesInput;
changesInput = {
hidden: {
currentValue: false
}
};
component.ngOnChanges(changesInput);
jasmine.clock().tick(101);
expect(component.closeButton.nativeElement.focus).toHaveBeenCalled();
});
it('test onModalClose method', () => {
const spyOnModalClosedEmit = spyOn(component.modalClosed, 'emit');
component.hidden = false;
component.onModalClose();
expect(component.hidden).toBe(true);
expect(spyOnModalClosedEmit).toHaveBeenCalled();
expect(spyOnModalClosedEmit).toHaveBeenCalledWith(true);
});
});