mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Introduce dependency to get random IDs
Co-authored-by: Janne Savolainen <janne.savolainen@live.fi> Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>
This commit is contained in:
parent
bff260f97d
commit
ff20645bbc
14
src/common/utils/get-random-id.injectable.ts
Normal file
14
src/common/utils/get-random-id.injectable.ts
Normal file
@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { v4 as getRandomId } from "uuid";
|
||||
|
||||
const getRandomIdInjectable = getInjectable({
|
||||
id: "get-random-id",
|
||||
instantiate: () => getRandomId,
|
||||
causesSideEffects: true,
|
||||
});
|
||||
|
||||
export default getRandomIdInjectable;
|
||||
@ -86,6 +86,7 @@ import startCatalogSyncInjectable from "./catalog-sync-to-renderer/start-catalog
|
||||
import startKubeConfigSyncInjectable from "./start-main-application/runnables/kube-config-sync/start-kube-config-sync.injectable";
|
||||
import startCheckingForUpdatesInjectable from "./application-update/periodical-check-for-updates/start-checking-for-updates.injectable";
|
||||
import appVersionInjectable from "../common/get-configuration-file-model/app-version/app-version.injectable";
|
||||
import getRandomIdInjectable from "../common/utils/get-random-id.injectable";
|
||||
|
||||
export function getDiForUnitTesting(opts: GetDiForUnitTestingOptions = {}) {
|
||||
const {
|
||||
@ -109,6 +110,7 @@ export function getDiForUnitTesting(opts: GetDiForUnitTestingOptions = {}) {
|
||||
di.preventSideEffects();
|
||||
|
||||
if (doGeneralOverrides) {
|
||||
di.override(getRandomIdInjectable, () => () => "some-irrelevant-random-id");
|
||||
di.override(hotbarStoreInjectable, () => ({ load: () => {} }));
|
||||
di.override(userStoreInjectable, () => ({ startMainReactions: () => {}, extensionRegistryUrl: { customUrl: "some-custom-url" }}) as UserStore);
|
||||
di.override(extensionsStoreInjectable, () => ({ isEnabled: (opts) => (void opts, false) }) as ExtensionsStore);
|
||||
|
||||
@ -45,6 +45,7 @@ import defaultShellInjectable from "./components/+preferences/default-shell.inje
|
||||
import appVersionInjectable from "../common/get-configuration-file-model/app-version/app-version.injectable";
|
||||
import provideInitialValuesForSyncBoxesInjectable from "./sync-box/provide-initial-values-for-sync-boxes.injectable";
|
||||
import requestAnimationFrameInjectable from "./components/animate/request-animation-frame.injectable";
|
||||
import getRandomIdInjectable from "../common/utils/get-random-id.injectable";
|
||||
|
||||
export const getDiForUnitTesting = (opts: GetDiForUnitTestingOptions = {}) => {
|
||||
const {
|
||||
@ -67,6 +68,7 @@ export const getDiForUnitTesting = (opts: GetDiForUnitTestingOptions = {}) => {
|
||||
di.preventSideEffects();
|
||||
|
||||
if (doGeneralOverrides) {
|
||||
di.override(getRandomIdInjectable, () => () => "some-irrelevant-random-id");
|
||||
di.override(isMacInjectable, () => true);
|
||||
di.override(isWindowsInjectable, () => false);
|
||||
di.override(isLinuxInjectable, () => false);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user