Skip to content

Commit

Permalink
fix: mock date for tests (difference local/CI)
Browse files Browse the repository at this point in the history
  • Loading branch information
SlyTed committed Jul 21, 2024
1 parent 0b47c76 commit f530232
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/helpers/cast/cast.helper.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ import { castArrayProperty, castToNumber } from './cast.helper';

describe('HELPERS - Cast', () => {
describe('castArrayProperty()', () => {
beforeAll(() => {
vi.useFakeTimers();
vi.setSystemTime(new Date('2000-01-01T00:00:00Z'));
});

afterAll(() => {
vi.useRealTimers();
});

test('Should return empty array if empty array provided', () => {
const data: TestModel<number>[] = [];
expect(castArrayProperty([] as TestModel<number>[], 'property')).toEqual(
Expand Down
9 changes: 9 additions & 0 deletions src/math/max-by/max-by.pipe.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ import type { TestModel } from 'test/test.model';
describe('MATH - Max by', () => {
let pipe: MaxByPipe = new MaxByPipe();

beforeAll(() => {
vi.useFakeTimers();
vi.setSystemTime(new Date('2000-01-01T00:00:00Z'));
});

afterAll(() => {
vi.useRealTimers();
});

beforeEach(() => {
pipe = new MaxByPipe();
});
Expand Down
9 changes: 9 additions & 0 deletions src/math/mean-by/mean-by.pipe.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ import type { TestModel } from 'test/test.model';
describe('MATH - Mean by', () => {
let pipe: MeanByPipe;

beforeAll(() => {
vi.useFakeTimers();
vi.setSystemTime(new Date('2000-01-01T00:00:00Z'));
});

afterAll(() => {
vi.useRealTimers();
});

beforeEach(() => {
pipe = new MeanByPipe();
});
Expand Down
9 changes: 9 additions & 0 deletions src/math/min-by/min-by.pipe.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ import type { TestModel } from 'test/test.model';
describe('MATH - Min by', () => {
let pipe: MinByPipe;

beforeAll(() => {
vi.useFakeTimers();
vi.setSystemTime(new Date('2000-01-01T00:00:00Z'));
});

afterAll(() => {
vi.useRealTimers();
});

beforeEach(() => {
pipe = new MinByPipe();
});
Expand Down
9 changes: 9 additions & 0 deletions src/math/sum-by/sum-by.pipe.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ import type { TestModel } from 'test/test.model';
describe('MATH - Sum by', () => {
let pipe: SumByPipe;

beforeAll(() => {
vi.useFakeTimers();
vi.setSystemTime(new Date('2000-01-01T00:00:00Z'));
});

afterAll(() => {
vi.useRealTimers();
});

beforeEach(() => {
pipe = new SumByPipe();
});
Expand Down

0 comments on commit f530232

Please sign in to comment.