-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #726 from aneoconsulting/add-statuses-group-dialog…
…-component-tests chore: tests for add statuses group dialog component
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
src/app/dashboard/components/add-statuses-group-dialog.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { TaskStatus } from '@aneoconsultingfr/armonik.api.angular'; | ||
import { TestBed } from '@angular/core/testing'; | ||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; | ||
import { AddStatusesGroupDialogComponent } from './add-statuses-group-dialog.component'; | ||
import { TasksStatusesGroup } from '../types'; | ||
|
||
describe('', () => { | ||
let component: AddStatusesGroupDialogComponent; | ||
|
||
const mockMatDialogRef = { | ||
close: jest.fn() | ||
}; | ||
|
||
beforeEach(() => { | ||
component = TestBed.configureTestingModule({ | ||
providers: [ | ||
AddStatusesGroupDialogComponent, | ||
{ provide: MatDialogRef, useValue: mockMatDialogRef }, | ||
{ provide: MAT_DIALOG_DATA, useValue: { | ||
statuses: [{ name: 'result', value: 'the-result' }] | ||
} } | ||
] | ||
}).inject(AddStatusesGroupDialogComponent); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('should init', () => { | ||
component.ngOnInit(); | ||
expect(component.statuses).toEqual([{ name: 'result', value: 'the-result' }]); | ||
}); | ||
|
||
it('should close with result on submit', () => { | ||
const group: TasksStatusesGroup = {name: 'status', color: 'green', statuses: [TaskStatus.TASK_STATUS_CANCELLED, TaskStatus.TASK_STATUS_COMPLETED]}; | ||
component.onSubmit(group); | ||
expect(mockMatDialogRef.close).toHaveBeenCalledWith(group); | ||
}); | ||
|
||
it('should close on "no" click', () => { | ||
component.onNoClick(); | ||
expect(mockMatDialogRef.close).toHaveBeenCalled(); | ||
}); | ||
}); |
a9bbc06
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JUnit
Files coverage (92%)