mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
- Remove CatalogEntityItem as it is a needless abstraction - Refix transparent background bug after bad rebase - Improve type safety around CatalogEntities by having CatalogEntitySpec be Partial<Record<string, unknown>> - Cleanup implementation of catalogSyncToRendererInjectable - Always use EntityPreferencesStore as an injectable Signed-off-by: Sebastian Malton <sebastian@malton.name> Make CatalogEntityRegistry.init redundent - Make all IPC injectable Signed-off-by: Sebastian Malton <sebastian@malton.name> Ensure that catalog is initialized during startFrame Signed-off-by: Sebastian Malton <sebastian@malton.name> Fix tests that overroad catalog sync - Actually use the catalog sync Signed-off-by: Sebastian Malton <sebastian@malton.name> Add behavioural tests Signed-off-by: Sebastian Malton <sebastian@malton.name> Don't assign in a computed Signed-off-by: Sebastian Malton <sebastian@malton.name> Make each store have a seperate migration version - Allows each store to only bump its version when necessary - Allows more decoupling from the extension API version so that PRs go stale slower Signed-off-by: Sebastian Malton <sebastian@malton.name> Add behavioural tests for short name length Signed-off-by: Sebastian Malton <sebastian@malton.name> Fix uses of testUsingTakeTime Signed-off-by: Sebastian Malton <sebastian@malton.name> Fix test flakiness by removing animate delay in tests Signed-off-by: Sebastian Malton <sebastian@malton.name> Update snapshots after removing timing sideeffects Signed-off-by: Sebastian Malton <sebastian@malton.name>
37 lines
926 B
TypeScript
37 lines
926 B
TypeScript
/**
|
|
* 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 interface TestUsingFakeTimeOptions {
|
|
dateTime?: string;
|
|
autoAdvance?: boolean;
|
|
}
|
|
|
|
export const testUsingFakeTime = ({ autoAdvance = false, dateTime: dateTime = "2015-10-21T07:28:00Z" }: TestUsingFakeTimeOptions = {}) => {
|
|
usingFakeTime = true;
|
|
|
|
const setInterval = global.setInterval;
|
|
|
|
jest.useFakeTimers();
|
|
|
|
if (autoAdvance) {
|
|
setInterval(() => advanceFakeTime(100), 100);
|
|
}
|
|
|
|
jest.setSystemTime(new Date(dateTime));
|
|
};
|