mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Replace all internal uses of utilities with new packages
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
3a2e436933
commit
ef32f2b72b
410 files changed
+1222
-825
No files matched your search
@@ -1,3 +1,5 @@
|
||||
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";
|
||||
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import type { Injectable } from "@ogre-tools/injectable";
|
||||
import { getGlobalOverride } from "./get-global-override";
|
||||
import { camelCase } from "lodash/fp";
|
||||
|
||||
export const getGlobalOverrideForFunction = (
|
||||
injectable: Injectable<Function, any, any>,
|
||||
) =>
|
||||
getGlobalOverride(injectable, () => (...args: any[]) => {
|
||||
console.warn(
|
||||
`Tried to invoke a function "${injectable.id}" without override. The args were:`,
|
||||
args,
|
||||
);
|
||||
|
||||
throw new Error(
|
||||
`Tried to invoke a function "${
|
||||
injectable.id
|
||||
}" without override. Add eg. "di.override(${camelCase(
|
||||
injectable.id,
|
||||
)}Mock)" to the unit test interested in this.`,
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import type { Injectable } from "@ogre-tools/injectable";
|
||||
|
||||
export interface GlobalOverride {
|
||||
injectable: Injectable<any, any, any>;
|
||||
overridingInstantiate: any;
|
||||
}
|
||||
|
||||
export const getGlobalOverride = <T extends Injectable<any, any, any>>(
|
||||
injectable: T,
|
||||
overridingInstantiate: T["instantiate"],
|
||||
) => ({
|
||||
injectable,
|
||||
overridingInstantiate,
|
||||
});
|
||||
Reference in new issue
Block a user