Skip to content

Commit

Permalink
mock new class function in test
Browse files Browse the repository at this point in the history
  • Loading branch information
kcinay055679 committed Oct 18, 2024
1 parent eaa9781 commit acbb7cc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { KeyResultMetric } from '../../shared/types/model/KeyResultMetric';
import { KeyResultOrdinal } from '../../shared/types/model/KeyResultOrdinal';
import { TranslateTestingModule } from 'ngx-translate-testing';
import * as de from '../../../assets/i18n/de.json';
import { Quarter } from '../../shared/types/model/Quarter';

describe('KeyResultFormComponent', () => {
let component: KeyResultFormComponent;
Expand Down Expand Up @@ -70,7 +71,7 @@ describe('KeyResultFormComponent', () => {
const keyResultObjective: KeyResultObjective = {
id: 2,
state: State.ONGOING,
quarter: { id: 1, label: 'GJ 22/23-Q2', endDate: new Date(), startDate: new Date() },
quarter: new Quarter(1, 'GJ 22/23-Q2', new Date(), new Date()),
};

const keyResultFormGroup = new FormGroup({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { QuarterFilterComponent } from './quarter-filter.component';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { OverviewService } from '../../services/overview.service';
import { quarter } from '../../shared/testData';
import { Observable, of } from 'rxjs';
import { Quarter } from '../../shared/types/model/Quarter';
import { QuarterService } from '../../services/quarter.service';
Expand Down Expand Up @@ -31,6 +30,9 @@ const quarterService = {
getAllQuarters(): Observable<Quarter[]> {
return of(quarters);
},
getCurrentQuarter(): Observable<Quarter> {
return of(quarters[2]);
},
};

describe('QuarterFilterComponent', () => {
Expand Down Expand Up @@ -68,6 +70,7 @@ describe('QuarterFilterComponent', () => {

it('should set correct default quarter if no route param is defined', async () => {
jest.spyOn(component, 'changeDisplayedQuarter');
jest.spyOn(quarters[2] as any, 'isCurrent').mockReturnValue(true);
const quarterSelect = await loader.getHarness(MatSelectHarness);
expect(quarterSelect).toBeTruthy();
component.ngOnInit();
Expand Down

0 comments on commit acbb7cc

Please sign in to comment.