Skip to content

Commit

Permalink
Add frontend tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lkleisa committed Jun 13, 2024
1 parent 7b57228 commit 5044f2c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
13 changes: 13 additions & 0 deletions frontend/src/app/overview/overview.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,19 @@ describe('OverviewComponent', () => {
expect(component.loadOverview).toHaveBeenLastCalledWith();
});

it('should correct set isArchiveQuarter', async () => {
let routerHarness = await RouterTestingHarness.create();
await routerHarness.navigateByUrl('/' + ['?quarter=998', 7, [], '']);
routerHarness.detectChanges();
component.loadOverviewWithParams();
expect(component.isArchiveQuarter).toBeTruthy();

await routerHarness.navigateByUrl('/' + ['?quarter=98', 7, [], '']);
routerHarness.detectChanges();
component.loadOverviewWithParams();
expect(component.isArchiveQuarter).toBeFalsy();
});

function markFiltersAsReady() {
refreshDataServiceMock.quarterFilterReady.next(null);
refreshDataServiceMock.teamFilterReady.next(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const quarterService = {
{ id: 1, startDate: quarter.startDate, endDate: quarter.endDate, label: quarter.label },
{ id: 2, startDate: quarter.startDate, endDate: quarter.endDate, label: quarter.label },
{ id: 199, startDate: null, endDate: null, label: 'Backlog' },
{ id: 998, startDate: null, endDate: null, label: 'Archiv' },
]);
},
};
Expand Down Expand Up @@ -254,6 +255,16 @@ describe('ObjectiveDialogComponent', () => {
expect(rawFormValue.quarter).toBe(objective.quarterId);
});

it('should remove archive as option in quarter list', async () => {
matDataMock.objective.objectiveId = 1;
const routerHarness = await RouterTestingHarness.create();
await routerHarness.navigateByUrl('/?quarter=2');
objectiveService.getFullObjective.mockReturnValue(of(objective));
component.ngOnInit();
expect(component.quarters.length).toBe(3);
expect(component.quarters[2].label).toBe('Backlog');
});

it('should return correct value if allowed to save to backlog', async () => {
component.quarters = quarterList;
const isBacklogQuarterSpy = jest.spyOn(component, 'isBacklogQuarter');
Expand Down

0 comments on commit 5044f2c

Please sign in to comment.