Skip to content

Commit

Permalink
Frontend: Add timestamp to RestService
Browse files Browse the repository at this point in the history
  • Loading branch information
Franceq34 authored and Quentin France committed May 6, 2022
1 parent 7df5836 commit f740bba
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 10 deletions.
9 changes: 4 additions & 5 deletions src/main/webapp/app/common/secondary/RestHistory.ts
Original file line number Diff line number Diff line change
@@ -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)),
});
6 changes: 6 additions & 0 deletions src/main/webapp/app/common/secondary/RestService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { RestServiceId } from '@/common/secondary/RestServiceId';

export interface RestService {
serviceId: RestServiceId;
timestamp: string;
}
19 changes: 15 additions & 4 deletions src/test/javascript/spec/common/secondary/RestHistory.fixture.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import { RestHistory } from '@/common/secondary/RestHistory';
import { createRestService } from './RestService.fixture';

export const createRestHistory = (restHistory?: Partial<RestHistory>): 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',
}),
];
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('RestHistory', () => {
const restHistory: RestHistory = createRestHistory();

expect(toHistory(restHistory)).toEqual<History>({
services: restHistory.serviceIds.map(toService),
services: restHistory.map(service => toService(service.serviceId)),
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { RestService } from '@/common/secondary/RestService';

export const createRestService = (restHistory?: Partial<RestService>): RestService => ({
serviceId: 'init',
timestamp: '2022-05-06T08:39:02.912804607Z',
...restHistory,
});

0 comments on commit f740bba

Please sign in to comment.