mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Revert moving "testUsingFakeTime" to separate package
- This fixes tests Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
ed53a2b955
commit
ffcaf0c54c
28 files changed
+31
-37
No files matched your search
@@ -2,4 +2,3 @@ export * from "./src/flush-promises";
|
||||
export * from "./src/get-global-override-for-function";
|
||||
export * from "./src/get-global-override";
|
||||
export * from "./src/get-promise-status";
|
||||
export * from "./src/use-fake-time";
|
||||
@@ -1,25 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { act } from "@testing-library/react";
|
||||
|
||||
let usingFakeTime = false;
|
||||
|
||||
export const advanceFakeTime = (milliseconds: number) => {
|
||||
if (!usingFakeTime) {
|
||||
throw new Error("Tried to advance fake time but it was not enabled. Call useFakeTime() first.");
|
||||
}
|
||||
|
||||
act(() => {
|
||||
jest.advanceTimersByTime(milliseconds);
|
||||
});
|
||||
};
|
||||
|
||||
export const testUsingFakeTime = (dateTime = "2015-10-21T07:28:00Z") => {
|
||||
usingFakeTime = true;
|
||||
|
||||
jest.useFakeTimers();
|
||||
|
||||
jest.setSystemTime(new Date(dateTime));
|
||||
};
|
||||
Reference in new issue
Block a user