mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
- Add route, clusterRoute, and payloadValidatedClusterRoute helper functions to improve types with backend routes - Turn on the following new lints: - react/jsx-first-prop-new-line - react/jsx-wrap-multilines - react/jsx-one-expression-per-line - react/jsx-max-props-per-line - react/jsx-indent - react/jsx-indent-props Signed-off-by: Sebastian Malton <sebastian@malton.name>
52 lines
1.6 KiB
TypeScript
52 lines
1.6 KiB
TypeScript
/**
|
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
*/
|
|
|
|
import { apiManager } from "../api-manager";
|
|
import { KubeApi } from "../kube-api";
|
|
import { KubeObject } from "../kube-object";
|
|
import { KubeObjectStore } from "../kube-object.store";
|
|
|
|
class TestApi extends KubeApi<KubeObject> {
|
|
protected async checkPreferredVersion() {
|
|
return;
|
|
}
|
|
}
|
|
|
|
class TestStore extends KubeObjectStore<KubeObject, TestApi> {
|
|
|
|
}
|
|
|
|
describe("ApiManager", () => {
|
|
describe("registerApi", () => {
|
|
it("re-register store if apiBase changed", async () => {
|
|
const apiBase = "apis/v1/foo";
|
|
const fallbackApiBase = "/apis/extensions/v1beta1/foo";
|
|
const kubeApi = new TestApi({
|
|
objectConstructor: KubeObject,
|
|
apiBase,
|
|
fallbackApiBases: [fallbackApiBase],
|
|
checkPreferredVersion: true,
|
|
});
|
|
const kubeStore = new TestStore(kubeApi);
|
|
|
|
apiManager.registerApi(apiBase, kubeApi);
|
|
|
|
// Define to use test api for ingress store
|
|
Object.defineProperty(kubeStore, "api", { value: kubeApi });
|
|
apiManager.registerStore(kubeStore, [kubeApi]);
|
|
|
|
// Test that store is returned with original apiBase
|
|
expect(apiManager.getStore(kubeApi)).toBe(kubeStore);
|
|
|
|
// Change apiBase similar as checkPreferredVersion does
|
|
Object.defineProperty(kubeApi, "apiBase", { value: fallbackApiBase });
|
|
apiManager.registerApi(fallbackApiBase, kubeApi);
|
|
|
|
// Test that store is returned with new apiBase
|
|
expect(apiManager.getStore(kubeApi)).toBe(kubeStore);
|
|
});
|
|
});
|
|
});
|