mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix stuff happening based on timers not being run correctly in unit tests (#5764)
* Introduce helper for advancing fake time Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Introduce reactive now to kludge around global shared state in library Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Replace all usages of "now" from mobx-utils with our own kludge to get rid of shared global state between unit tests Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Consolidate all usages of advanceTimersByTime to make sure things happening based on timers are run correctly Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Fix incorrect expect in test Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Enable skipped unit test since prerequisites are done Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
1 parent
3480b517c1
commit
5f57213179
13 files changed
+190
-30
No files matched your search
@@ -15,7 +15,7 @@ import type { UpdateIsBeingDownloaded } from "../../../common/application-update
|
||||
import updateIsBeingDownloadedInjectable from "../../../common/application-update/update-is-being-downloaded/update-is-being-downloaded.injectable";
|
||||
import type { UpdatesAreBeingDiscovered } from "../../../common/application-update/updates-are-being-discovered/updates-are-being-discovered.injectable";
|
||||
import updatesAreBeingDiscoveredInjectable from "../../../common/application-update/updates-are-being-discovered/updates-are-being-discovered.injectable";
|
||||
import { now as reactiveDateNow } from "mobx-utils";
|
||||
import { reactiveNow } from "../../../common/utils/reactive-now/reactive-now";
|
||||
|
||||
interface Dependencies {
|
||||
progressOfUpdateDownload: ProgressOfUpdateDownload;
|
||||
@@ -32,10 +32,10 @@ interface EndNoteProps {
|
||||
const EndNote = observer(({ version, note }: EndNoteProps) => {
|
||||
const [start] = useState(Date.now());
|
||||
|
||||
if (start + 5000 <= reactiveDateNow()) {
|
||||
if (start + 5000 <= reactiveNow()) {
|
||||
return idle();
|
||||
}
|
||||
|
||||
|
||||
return note(version ?? "");
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user