diff --git a/frontend/src/app/shared/services/overview.service.spec.ts b/frontend/src/app/shared/services/overview.service.spec.ts index ec99a7031a..3a8c83b35d 100644 --- a/frontend/src/app/shared/services/overview.service.spec.ts +++ b/frontend/src/app/shared/services/overview.service.spec.ts @@ -4,8 +4,7 @@ import { OverviewService } from './overview.service'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { of } from 'rxjs'; import { HttpClient } from '@angular/common/http'; -import { State } from '../types/enums/State'; -import { overViewEntity1, quarter } from '../testData'; +import { dashboard } from '../testData'; const httpClient = { get: jest.fn(), @@ -20,12 +19,19 @@ describe('OverviewService', () => { providers: [{ provide: HttpClient, useValue: httpClient }], }).compileComponents(); service = TestBed.inject(OverviewService); - httpClient.get.mockReturnValue( - of([{ ...overViewEntity1, objectives: { ...overViewEntity1.objectives[0], state: 'DRAFT' } }]), - ); }); it('should be created', () => { expect(service).toBeTruthy(); }); + + it('should set state of objectives correctly', (done) => { + jest.spyOn(httpClient, 'get').mockReturnValue(of(dashboard)); + service.getOverview().subscribe((dashboard) => { + dashboard.overviews.forEach((overview) => + overview.objectives.forEach((objective) => expect(typeof objective.state).toBe('string')), + ); + done(); + }); + }); }); diff --git a/frontend/src/app/shared/testData.ts b/frontend/src/app/shared/testData.ts index 3146cb7eb2..a61fbaaa62 100644 --- a/frontend/src/app/shared/testData.ts +++ b/frontend/src/app/shared/testData.ts @@ -19,6 +19,7 @@ import { Team } from './types/model/Team'; import { Action } from './types/model/Action'; import { OrganisationState } from './types/enums/OrganisationState'; import { Organisation } from './types/model/Organisation'; +import { Dashboard } from './types/model/Dashboard'; export const organisationActive = { id: 1, @@ -241,6 +242,43 @@ export const objectiveMin: ObjectiveMin = { quarter: quarterMin, keyResults: [keyResultMetricMin, keyResultOrdinalMin] as KeyresultMin[], } as ObjectiveMin; + +export const objectiveResponse1: any = { + id: 101, + version: 1, + title: 'Increase Environment Engagement', + state: 'ONGOING', + quarter: quarterMin, + keyResults: [keyResultMetricMin, keyResultOrdinalMin] as KeyresultMin[], +}; + +export const objectiveResponse2: any = { + id: 102, + version: 1, + title: 'Increase Social Engagement', + state: 'DRAFT', + quarter: quarterMin, + keyResults: [keyResultMetricMin, keyResultOrdinalMin] as KeyresultMin[], +}; + +export const objectiveResponse3: any = { + id: 103, + version: 1, + title: 'Increase Member Engagement', + state: 'NOTSUCCESSFUL', + quarter: quarterMin, + keyResults: [keyResultMetricMin, keyResultOrdinalMin] as KeyresultMin[], +}; + +export const objectiveResponse4: any = { + id: 104, + version: 1, + title: 'Increase Company Engagement', + state: 'SUCCESSFUL', + quarter: quarterMin, + keyResults: [keyResultMetricMin, keyResultOrdinalMin] as KeyresultMin[], +}; + export const overViewEntity1: OverviewEntity = { team: teamMin1, objectives: [objectiveMin, objectiveMin, objectiveMin] as ObjectiveMin[], @@ -253,6 +291,23 @@ export const overViewEntity2: OverviewEntity = { writable: true, }; +export const overViewEntityResponse1: any = { + team: team1, + objectives: [objectiveResponse1, objectiveResponse2], + writable: true, +}; + +export const overViewEntityResponse2: any = { + team: team2, + objectives: [objectiveResponse3, objectiveResponse4], + writable: false, +}; + +export const dashboard: Dashboard = { + overviews: [overViewEntityResponse1, overViewEntityResponse2], + adminAccess: true, +}; + export const quarter: Quarter = { id: 1, label: '23.02.2025',