-
Notifications
You must be signed in to change notification settings - Fork 470
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
30 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
/// <reference types="jest" /> | ||
import {afterAll, beforeAll} from '@jest/globals'; | ||
import {tuiSwitchNgDevMode} from '@taiga-ui/testing/mocks'; | ||
import {setupZoneTestEnv} from 'jest-preset-angular/setup-env/zone'; | ||
|
||
|
@@ -143,6 +144,27 @@ class TransferMockEvent { | |
global.DragEvent = TransferMockEvent as unknown as typeof DragEvent; | ||
global.ClipboardEvent = TransferMockEvent as unknown as typeof ClipboardEvent; | ||
|
||
class OriginalDate extends Date {} | ||
|
||
const fakeTime = '2023-02-15T00:00:00Z'; | ||
const fakeNow = new Date(fakeTime).getTime(); | ||
|
||
class MockDate extends Date { | ||
constructor(...args: DateConstructor[]) { | ||
// @ts-ignore | ||
Check warning on line 154 in projects/testing/setup-jest/index.ts codefactor.io / CodeFactorprojects/testing/setup-jest/index.ts#L154
|
||
super(...(args.length === 0 ? [fakeTime] : args)); | ||
} | ||
} | ||
|
||
beforeAll(() => { | ||
global.Date = MockDate as unknown as DateConstructor; | ||
global.Date.now = () => fakeNow; | ||
}); | ||
|
||
afterAll(() => { | ||
global.Date = OriginalDate as unknown as DateConstructor; | ||
}); | ||
|
||
/** | ||
* in our jest setupFilesAfterEnv file, | ||
* however when running with ng test those | ||
|