From f740bba6ab9a7ee19dc6be14444be2af5704b07e Mon Sep 17 00:00:00 2001 From: Quentin France Date: Fri, 6 May 2022 10:56:04 +0200 Subject: [PATCH] Frontend: Add timestamp to RestService --- .../app/common/secondary/RestHistory.ts | 9 ++++----- .../app/common/secondary/RestService.ts | 6 ++++++ .../common/secondary/RestHistory.fixture.ts | 19 +++++++++++++++---- .../spec/common/secondary/RestHistory.spec.ts | 2 +- .../common/secondary/RestService.fixture.ts | 7 +++++++ 5 files changed, 33 insertions(+), 10 deletions(-) create mode 100644 src/main/webapp/app/common/secondary/RestService.ts create mode 100644 src/test/javascript/spec/common/secondary/RestService.fixture.ts diff --git a/src/main/webapp/app/common/secondary/RestHistory.ts b/src/main/webapp/app/common/secondary/RestHistory.ts index c639fa16e81..2f97679bc2e 100644 --- a/src/main/webapp/app/common/secondary/RestHistory.ts +++ b/src/main/webapp/app/common/secondary/RestHistory.ts @@ -1,10 +1,9 @@ -import { RestServiceId, toService } from '@/common/secondary/RestServiceId'; +import { toService } from '@/common/secondary/RestServiceId'; import { History } from '@/common/domain/History'; +import { RestService } from '@/common/secondary/RestService'; -export interface RestHistory { - serviceIds: RestServiceId[]; -} +export type RestHistory = RestService[]; export const toHistory = (restHistory: RestHistory): History => ({ - services: restHistory.serviceIds.map(toService), + services: restHistory.map(service => toService(service.serviceId)), }); diff --git a/src/main/webapp/app/common/secondary/RestService.ts b/src/main/webapp/app/common/secondary/RestService.ts new file mode 100644 index 00000000000..572668bb5ac --- /dev/null +++ b/src/main/webapp/app/common/secondary/RestService.ts @@ -0,0 +1,6 @@ +import { RestServiceId } from '@/common/secondary/RestServiceId'; + +export interface RestService { + serviceId: RestServiceId; + timestamp: string; +} diff --git a/src/test/javascript/spec/common/secondary/RestHistory.fixture.ts b/src/test/javascript/spec/common/secondary/RestHistory.fixture.ts index c41fe72b543..83fc21ef280 100644 --- a/src/test/javascript/spec/common/secondary/RestHistory.fixture.ts +++ b/src/test/javascript/spec/common/secondary/RestHistory.fixture.ts @@ -1,6 +1,17 @@ import { RestHistory } from '@/common/secondary/RestHistory'; +import { createRestService } from './RestService.fixture'; -export const createRestHistory = (restHistory?: Partial): RestHistory => ({ - serviceIds: ['init', 'java-base', 'maven-java'], - ...restHistory, -}); +export const createRestHistory = (): RestHistory => [ + createRestService({ + serviceId: 'init', + timestamp: '2022-05-06T08:39:02.912804607Z', + }), + createRestService({ + serviceId: 'java-base', + timestamp: '2022-05-07T08:39:02.912804607Z', + }), + createRestService({ + serviceId: 'maven-java', + timestamp: '2022-05-08T08:39:02.912804607Z', + }), +]; diff --git a/src/test/javascript/spec/common/secondary/RestHistory.spec.ts b/src/test/javascript/spec/common/secondary/RestHistory.spec.ts index 9252f766638..f8d5726eb54 100644 --- a/src/test/javascript/spec/common/secondary/RestHistory.spec.ts +++ b/src/test/javascript/spec/common/secondary/RestHistory.spec.ts @@ -8,7 +8,7 @@ describe('RestHistory', () => { const restHistory: RestHistory = createRestHistory(); expect(toHistory(restHistory)).toEqual({ - services: restHistory.serviceIds.map(toService), + services: restHistory.map(service => toService(service.serviceId)), }); }); }); diff --git a/src/test/javascript/spec/common/secondary/RestService.fixture.ts b/src/test/javascript/spec/common/secondary/RestService.fixture.ts new file mode 100644 index 00000000000..46f30d2f33e --- /dev/null +++ b/src/test/javascript/spec/common/secondary/RestService.fixture.ts @@ -0,0 +1,7 @@ +import { RestService } from '@/common/secondary/RestService'; + +export const createRestService = (restHistory?: Partial): RestService => ({ + serviceId: 'init', + timestamp: '2022-05-06T08:39:02.912804607Z', + ...restHistory, +});