Unit tests added

This commit is contained in:
Piotr Pekala 2019-08-20 05:49:54 -07:00
parent af4ef62132
commit 8163b4d709
3 changed files with 27 additions and 1 deletions

View File

@ -40,7 +40,7 @@
<button mat-icon-button matTooltip="Delete project" (click)="delete(row)" *ngIf="row.status == 'closed'">
<mat-icon aria-label="Delete project">delete</mat-icon>
</button>
<button mat-icon-button matTooltip="Duplicate project" (click)="duplicate(row)">
<button mat-icon-button matTooltip="Duplicate project" (click)="duplicate(row)" *ngIf="row.status == 'closed'">
<mat-icon aria-label="Duplicate project">filter_2</mat-icon>
</button>
<button mat-icon-button matTooltip="Open project" (click)="open(row)" *ngIf="row.status == 'closed'">

View File

@ -85,6 +85,28 @@ describe('ProjectsComponent', () => {
expect(mockedProjectService.delete).toHaveBeenCalled();
});
it('should call project service after duplicate action', () => {
spyOn(mockedProjectService, 'duplicate').and.returnValue(of());
let project = new Project();
project.project_id = '1';
project.status = 'closed';
component.duplicate(project);
expect(mockedProjectService.duplicate).toHaveBeenCalled();
});
it('should call refresh after duplicate action', () => {
spyOn(component, 'refresh');
let project = new Project();
project.project_id = '1';
project.status = 'closed';
component.duplicate(project);
expect(component.refresh).toHaveBeenCalled();
});
describe('ProjectComponent open', () => {
let project: Project;

View File

@ -41,6 +41,10 @@ export class MockedProjectService {
delete(server: Server, project_id: string) {
return of(project_id);
}
duplicate(server: Server, project_id: string) {
return of(project_id);
}
}
describe('ProjectService', () => {