From 6708a73ac9b3485839c33cc4200722884059b4eb Mon Sep 17 00:00:00 2001 From: Julian Gassner Date: Fri, 10 Jan 2025 04:29:27 +0100 Subject: [PATCH] Add mock for tests --- .../mocks/service/mock-artemis-server-date.service.ts | 7 +++++++ .../javascript/spec/pipe/artemis-time-ago.pipe.spec.ts | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 src/test/javascript/spec/helpers/mocks/service/mock-artemis-server-date.service.ts diff --git a/src/test/javascript/spec/helpers/mocks/service/mock-artemis-server-date.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-artemis-server-date.service.ts new file mode 100644 index 000000000000..fc222ae1d9b2 --- /dev/null +++ b/src/test/javascript/spec/helpers/mocks/service/mock-artemis-server-date.service.ts @@ -0,0 +1,7 @@ +import dayjs from 'dayjs/esm'; + +export class MockArtemisServerDateService { + now(): dayjs.Dayjs { + return dayjs(); + } +} diff --git a/src/test/javascript/spec/pipe/artemis-time-ago.pipe.spec.ts b/src/test/javascript/spec/pipe/artemis-time-ago.pipe.spec.ts index d279b9404c55..6d2f2fcbaa7d 100644 --- a/src/test/javascript/spec/pipe/artemis-time-ago.pipe.spec.ts +++ b/src/test/javascript/spec/pipe/artemis-time-ago.pipe.spec.ts @@ -5,6 +5,7 @@ import { TranslateService } from '@ngx-translate/core'; import { ChangeDetectorRef, NgZone } from '@angular/core'; import { ArtemisServerDateService } from 'app/shared/server-date.service'; import dayjs from 'dayjs/esm'; +import { MockArtemisServerDateService } from '../helpers/mocks/service/mock-artemis-server-date.service'; describe('ArtemisTimeAgoPipe', () => { let pipe: ArtemisTimeAgoPipe; @@ -15,7 +16,10 @@ describe('ArtemisTimeAgoPipe', () => { beforeEach(() => { TestBed.configureTestingModule({ declarations: [ArtemisTimeAgoPipe], - providers: [{ provide: TranslateService, useClass: MockTranslateService }], + providers: [ + { provide: TranslateService, useClass: MockTranslateService }, + { provide: ArtemisServerDateService, useClass: MockArtemisServerDateService }, + ], }) .compileComponents() .then(() => {