Skip to content

Commit

Permalink
Add mock for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
badkeyy committed Jan 10, 2025
1 parent db171a6 commit 6708a73
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import dayjs from 'dayjs/esm';

export class MockArtemisServerDateService {
now(): dayjs.Dayjs {
return dayjs();
}
}
6 changes: 5 additions & 1 deletion src/test/javascript/spec/pipe/artemis-time-ago.pipe.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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(() => {
Expand Down

0 comments on commit 6708a73

Please sign in to comment.