Persist apiVersion when editing resources in monaco (#4406)

* Persist apiVersion when editing resources in monaco

- Use a new custom k8slens prefixed label

- Means that users aren't surprised when they use lens to update a
  resource to a new apiVersionWithGroup

- Doesn't touch the versions in the stores

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Fix lint

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* fix: Fix lint issues

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* chore: make lint not bail on failure

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* chore: Run lint:fix on all files

Signed-off-by: Sebastian Malton <sebastian@malton.name>

---------

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton authored and GitHub committed 2023-04-05 10:56:23 -04:00
1 parent 058494bc73
commit 807f98ed1b
57 files changed
+295 -400

No files matched your search

@@ -13,9 +13,7 @@ const startApplicationInjectable = getInjectable({
instantiate: (di): StartApplication => {
const runManyAsync = runManyFor(di);
const beforeApplicationIsLoading = runManyAsync(
timeSlots.beforeApplicationIsLoadingInjectionToken,
);
const beforeApplicationIsLoading = runManyAsync(timeSlots.beforeApplicationIsLoadingInjectionToken);
const onLoadOfApplication = runManyAsync(timeSlots.onLoadOfApplicationInjectionToken);
const afterApplicationIsLoaded = runManyAsync(timeSlots.afterApplicationIsLoadedInjectionToken);
@@ -1,9 +1,4 @@
import {
DiContainer,
getInjectable,
instantiationDecoratorToken,
lifecycleEnum,
} from "@ogre-tools/injectable";
import { DiContainer, getInjectable, instantiationDecoratorToken, lifecycleEnum } from "@ogre-tools/injectable";
import { startApplicationInjectionToken } from "@k8slens/application";
import whenAppIsReadyInjectable from "./when-app-is-ready.injectable";
import { beforeAnythingInjectionToken, beforeElectronIsReadyInjectionToken } from "./time-slots";
@@ -1,10 +1,7 @@
import { createContainer, DiContainer, getInjectable } from "@ogre-tools/injectable";
import { registerFeature } from "@k8slens/feature-core";
import { applicationFeatureForElectronMain } from "./feature";
import {
beforeApplicationIsLoadingInjectionToken,
startApplicationInjectionToken,
} from "@k8slens/application";
import { beforeApplicationIsLoadingInjectionToken, startApplicationInjectionToken } from "@k8slens/application";
import asyncFn, { AsyncFnMock } from "@async-fn/jest";
import whenAppIsReadyInjectable from "./start-application/when-app-is-ready.injectable";
import * as timeSlots from "./start-application/time-slots";
@@ -2,9 +2,7 @@ import type { DiContainer } from "@ogre-tools/injectable";
import type { Feature } from "./feature";
import { featureContextMapInjectable } from "./feature-context-map-injectable";
const getDependingFeaturesFor = (
featureContextMap: Map<Feature, { dependedBy: Map<Feature, number> }>,
) => {
const getDependingFeaturesFor = (featureContextMap: Map<Feature, { dependedBy: Map<Feature, number> }>) => {
const getDependingFeaturesForRecursion = (feature: Feature, atRoot = true): string[] => {
const context = featureContextMap.get(feature);
@@ -36,11 +34,9 @@ const deregisterFeatureRecursed = (di: DiContainer, feature: Feature, dependedBy
const dependingFeatures = getDependingFeatures(feature);
if (!dependedBy && dependingFeatures.length) {
throw new Error(
`Tried to deregister Feature "${
feature.id
}", but it is the dependency of Features "${dependingFeatures.join(", ")}"`,
);
const names = dependingFeatures.join(", ");
throw new Error(`Tried to deregister Feature "${feature.id}", but it is the dependency of Features "${names}"`);
}
if (dependedBy) {
@@ -59,9 +59,7 @@ describe("feature-dependencies", () => {
expect(() => {
deregisterFeature(di, someDependencyFeature);
}).toThrow(
'Tried to deregister feature "some-dependency-feature", but it was not registered.',
);
}).toThrow('Tried to deregister feature "some-dependency-feature", but it was not registered.');
});
it("given the parent Feature is deregistered, when injecting an injectable from the dependency Feature, throws", () => {
@@ -104,9 +102,7 @@ describe("feature-dependencies", () => {
it("when the first Feature is deregistered, throws", () => {
expect(() => {
deregisterFeature(di, someFeature1);
}).toThrow(
'Tried to deregister Feature "some-feature-1", but it is the dependency of Features "some-feature-2"',
);
}).toThrow('Tried to deregister Feature "some-feature-1", but it is the dependency of Features "some-feature-2"');
});
it("given the second Feature is deregistered, when injecting an injectable from the first Feature, still does so", () => {
@@ -180,9 +176,7 @@ describe("feature-dependencies", () => {
expect(() => {
di.inject(someInjectableInDependencyFeature);
}).toThrow(
'Tried to inject non-registered injectable "irrelevant" -> "some-injectable-in-dependency-feature".',
);
}).toThrow('Tried to inject non-registered injectable "irrelevant" -> "some-injectable-in-dependency-feature".');
});
});
@@ -256,9 +250,7 @@ describe("feature-dependencies", () => {
expect(() => {
di.inject(someInjectableInDependencyFeature);
}).toThrow(
'Tried to inject non-registered injectable "irrelevant" -> "some-injectable-in-dependency-feature".',
);
}).toThrow('Tried to inject non-registered injectable "irrelevant" -> "some-injectable-in-dependency-feature".');
});
});
});
@@ -1,10 +1,7 @@
import type { DiContainer } from "@ogre-tools/injectable";
import { getInjectable } from "@ogre-tools/injectable";
import type { Feature } from "./feature";
import {
featureContextMapInjectable,
featureContextMapInjectionToken,
} from "./feature-context-map-injectable";
import { featureContextMapInjectable, featureContextMapInjectionToken } from "./feature-context-map-injectable";
const createFeatureContext = (feature: Feature, di: DiContainer) => {
const featureContextInjectable = getInjectable({
@@ -58,10 +55,9 @@ const registerFeatureRecursed = (di: DiContainer, feature: Feature, dependedBy?:
if (dependedBy) {
const oldNumberOfDependents = featureContext.dependedBy.get(dependedBy) || 0;
const newNumberOfDependents = oldNumberOfDependents + 1;
const newNumberOfDependants = oldNumberOfDependents + 1;
featureContext.dependedBy.set(dependedBy, newNumberOfDependants);
featureContext.dependedBy.set(dependedBy, newNumberOfDependents);
}
if (!existingFeatureContext) {
@@ -21,15 +21,9 @@ export {
getMessageChannelListenerInjectable,
} from "./message/message-channel-listener-injection-token";
export type {
RequestChannel,
RequestChannelHandler,
} from "./request/request-channel-listener-injection-token";
export type { RequestChannel, RequestChannelHandler } from "./request/request-channel-listener-injection-token";
export type {
RequestFromChannel,
ChannelRequester,
} from "./request/request-from-channel-injection-token";
export type { RequestFromChannel, ChannelRequester } from "./request/request-from-channel-injection-token";
export type { EnlistMessageChannelListener } from "./message/enlist-message-channel-listener-injection-token";
export { enlistMessageChannelListenerInjectionToken } from "./message/enlist-message-channel-listener-injection-token";
@@ -21,9 +21,7 @@ export const listeningOfChannelsInjectionToken = getInjectionToken<ListeningOfCh
id: "listening-of-channels-injection-token",
});
const listening = <
T extends { id: string; channel: MessageChannel<any> | RequestChannel<any, any> },
>(
const listening = <T extends { id: string; channel: MessageChannel<any> | RequestChannel<any, any> }>(
channelListeners: IComputedValue<T[]>,
enlistChannelListener: (listener: T) => () => void,
getId: (listener: T) => string,
@@ -33,9 +31,7 @@ const listening = <
const reactionDisposer = reaction(
() => channelListeners.get(),
(newValues, oldValues = []) => {
const addedListeners = newValues.filter(
(newValue) => !oldValues.some((oldValue) => oldValue.id === newValue.id),
);
const addedListeners = newValues.filter((newValue) => !oldValues.some((oldValue) => oldValue.id === newValue.id));
const removedListeners = oldValues.filter(
(oldValue) => !newValues.some((newValue) => newValue.id === oldValue.id),
@@ -45,9 +41,7 @@ const listening = <
const id = getId(listener);
if (listenerDisposers.has(id)) {
throw new Error(
`Tried to add listener for channel "${listener.channel.id}" but listener already exists.`,
);
throw new Error(`Tried to add listener for channel "${listener.channel.id}" but listener already exists.`);
}
const disposer = enlistChannelListener(listener);
@@ -1,16 +1,10 @@
import type { Disposer } from "@k8slens/utilities";
import { getInjectionToken } from "@ogre-tools/injectable";
import type {
MessageChannel,
MessageChannelListener,
} from "./message-channel-listener-injection-token";
import type { MessageChannel, MessageChannelListener } from "./message-channel-listener-injection-token";
export type EnlistMessageChannelListener = <T>(
listener: MessageChannelListener<MessageChannel<T>>,
) => Disposer;
export type EnlistMessageChannelListener = <T>(listener: MessageChannelListener<MessageChannel<T>>) => Disposer;
export const enlistMessageChannelListenerInjectionToken =
getInjectionToken<EnlistMessageChannelListener>({
id: "listening-to-a-message-channel",
});
export const enlistMessageChannelListenerInjectionToken = getInjectionToken<EnlistMessageChannelListener>({
id: "listening-to-a-message-channel",
});
@@ -18,9 +18,7 @@ export interface MessageChannelListener<Channel> {
handler: MessageChannelHandler<Channel>;
}
export const messageChannelListenerInjectionToken = getInjectionToken<
MessageChannelListener<MessageChannel<unknown>>
>({
export const messageChannelListenerInjectionToken = getInjectionToken<MessageChannelListener<MessageChannel<unknown>>>({
id: "message-channel-listener",
});
@@ -31,10 +29,7 @@ export interface GetMessageChannelListenerInfo<Channel extends MessageChannel<Me
causesSideEffects?: boolean;
}
export const getMessageChannelListenerInjectable = <
Channel extends MessageChannel<Message>,
Message,
>(
export const getMessageChannelListenerInjectable = <Channel extends MessageChannel<Message>, Message>(
info: GetMessageChannelListenerInfo<Channel, Message>,
) =>
getInjectable({
@@ -1,16 +1,12 @@
import type { Disposer } from "@k8slens/utilities/index";
import { getInjectionToken } from "@ogre-tools/injectable";
import type {
RequestChannel,
RequestChannelListener,
} from "./request-channel-listener-injection-token";
import type { RequestChannel, RequestChannelListener } from "./request-channel-listener-injection-token";
export type EnlistRequestChannelListener = <Request, Response>(
listener: RequestChannelListener<RequestChannel<Request, Response>>,
) => Disposer;
export const enlistRequestChannelListenerInjectionToken =
getInjectionToken<EnlistRequestChannelListener>({
id: "listening-to-a-request-channel",
});
export const enlistRequestChannelListenerInjectionToken = getInjectionToken<EnlistRequestChannelListener>({
id: "listening-to-a-request-channel",
});
@@ -1,7 +1,5 @@
import type { RequestChannel } from "./request-channel-listener-injection-token";
export const getRequestChannel = <Request, Response>(
id: string,
): RequestChannel<Request, Response> => ({
export const getRequestChannel = <Request, Response>(id: string): RequestChannel<Request, Response> => ({
id,
});
@@ -7,10 +7,7 @@ export interface RequestChannel<Request, Response> {
_responseSignature?: Response;
}
export type RequestChannelHandler<Channel> = Channel extends RequestChannel<
infer Request,
infer Response
>
export type RequestChannelHandler<Channel> = Channel extends RequestChannel<infer Request, infer Response>
? (req: Request) => Promise<Response> | Response
: never;
@@ -2,17 +2,11 @@ import { getInjectionToken } from "@ogre-tools/injectable";
import type { RequestChannel } from "./request-channel-listener-injection-token";
export interface RequestFromChannel {
<Request, Response>(
channel: RequestChannel<Request, Response>,
request: Request,
): Promise<Response>;
<Request, Response>(channel: RequestChannel<Request, Response>, request: Request): Promise<Response>;
<Response>(channel: RequestChannel<void, Response>): Promise<Response>;
}
export type ChannelRequester<Channel> = Channel extends RequestChannel<
infer Request,
infer Response
>
export type ChannelRequester<Channel> = Channel extends RequestChannel<infer Request, infer Response>
? (req: Request) => Promise<Awaited<Response>>
: never;
@@ -121,9 +121,7 @@ describe("listening-of-requests", () => {
runInAction(() => {
di.register(someConflictingListenerInjectable);
});
}).toThrow(
'Tried to add listener for channel "some-channel-id" but listener already exists.',
);
}).toThrow('Tried to add listener for channel "some-channel-id" but listener already exists.');
});
describe("when another listener gets registered", () => {
@@ -3,7 +3,4 @@ export {
computedChannelObserverInjectionToken,
} from "./src/computed-channel/computed-channel.injectable";
export type {
ChannelObserver,
ComputedChannelFactory,
} from "./src/computed-channel/computed-channel.injectable";
export type { ChannelObserver, ComputedChannelFactory } from "./src/computed-channel/computed-channel.injectable";
@@ -1,23 +1,13 @@
import { getInjectable, getInjectionToken } from "@ogre-tools/injectable";
import {
computed,
IComputedValue,
observable,
onBecomeObserved,
onBecomeUnobserved,
runInAction,
} from "mobx";
import { computed, IComputedValue, observable, onBecomeObserved, onBecomeUnobserved, runInAction } from "mobx";
import type { MessageChannel } from "@k8slens/messaging";
import { getMessageChannelListenerInjectable } from "@k8slens/messaging";
import { sendMessageToChannelInjectionToken } from "@k8slens/messaging";
import { computedChannelAdministrationChannel } from "./computed-channel-administration-channel.injectable";
export type ComputedChannelFactory = <T>(
channel: MessageChannel<T>,
pendingValue: T,
) => IComputedValue<T>;
export type ComputedChannelFactory = <T>(channel: MessageChannel<T>, pendingValue: T) => IComputedValue<T>;
export const computedChannelInjectionToken = getInjectionToken<ComputedChannelFactory>({
id: "computed-channel-injection-token",
@@ -3,23 +3,13 @@ import { act } from "@testing-library/react";
import { createContainer, DiContainer, getInjectable } from "@ogre-tools/injectable";
import { getMessageBridgeFake, MessageBridgeFake } from "@k8slens/messaging-fake-bridge";
import { startApplicationInjectionToken } from "@k8slens/application";
import {
computed,
IComputedValue,
IObservableValue,
observable,
reaction,
runInAction,
} from "mobx";
import { computed, IComputedValue, IObservableValue, observable, reaction, runInAction } from "mobx";
import type { MessageChannel } from "@k8slens/messaging";
import { getMessageChannelListenerInjectable } from "@k8slens/messaging";
import { registerMobX } from "@ogre-tools/injectable-extension-for-mobx";
import { registerFeature } from "@k8slens/feature-core";
import { testUtils } from "@k8slens/messaging";
import {
computedChannelInjectionToken,
computedChannelObserverInjectionToken,
} from "./computed-channel.injectable";
import { computedChannelInjectionToken, computedChannelObserverInjectionToken } from "./computed-channel.injectable";
import { runWithThrownMobxReactions, renderFor } from "@k8slens/test-utils";
import { observer } from "mobx-react";
import {
@@ -36,9 +26,7 @@ const TestComponent = observer(({ someComputed }: { someComputed: IComputedValue
));
[{ scenarioIsAsync: true }, { scenarioIsAsync: false }].forEach(({ scenarioIsAsync }) =>
describe(`computed-channel, given running message bridge fake as ${
scenarioIsAsync ? "async" : "sync"
}`, () => {
describe(`computed-channel, given running message bridge fake as ${scenarioIsAsync ? "async" : "sync"}`, () => {
describe("given multiple dis and a message channel and a channel observer and application has started", () => {
let di1: DiContainer;
let di2: DiContainer;
@@ -87,10 +75,7 @@ const TestComponent = observer(({ someComputed }: { someComputed: IComputedValue
messageBridgeFake.setAsync(scenarioIsAsync);
messageBridgeFake.involve(di1, di2);
await Promise.all([
di1.inject(startApplicationInjectionToken)(),
di2.inject(startApplicationInjectionToken)(),
]);
await Promise.all([di1.inject(startApplicationInjectionToken)(), di2.inject(startApplicationInjectionToken)()]);
});
describe("given a channel observer and matching computed channel for the channel in di-2", () => {
@@ -175,9 +160,7 @@ const TestComponent = observer(({ someComputed }: { someComputed: IComputedValue
expect(observedValue).toBe("some-pending-value");
});
const scenarioName = scenarioIsAsync
? "when admin messages are propagated"
: "immediately";
const scenarioName = scenarioIsAsync ? "when admin messages are propagated" : "immediately";
// eslint-disable-next-line jest/valid-title
describe(scenarioName, () => {
@@ -196,9 +179,7 @@ const TestComponent = observer(({ someComputed }: { someComputed: IComputedValue
});
});
const scenarioName = scenarioIsAsync
? "when returning value-messages propagate"
: "immediately";
const scenarioName = scenarioIsAsync ? "when returning value-messages propagate" : "immediately";
// eslint-disable-next-line jest/valid-title
describe(scenarioName, () => {
@@ -227,9 +208,7 @@ const TestComponent = observer(({ someComputed }: { someComputed: IComputedValue
});
});
const scenarioName = scenarioIsAsync
? "when value-messages propagate"
: "immediately";
const scenarioName = scenarioIsAsync ? "when value-messages propagate" : "immediately";
// eslint-disable-next-line jest/valid-title
describe(scenarioName, () => {
@@ -258,9 +237,7 @@ const TestComponent = observer(({ someComputed }: { someComputed: IComputedValue
stopObserving();
});
const scenarioName = scenarioIsAsync
? "when admin-messages propagate"
: "immediately";
const scenarioName = scenarioIsAsync ? "when admin-messages propagate" : "immediately";
// eslint-disable-next-line jest/valid-title
describe(scenarioName, () => {
@@ -317,9 +294,7 @@ const TestComponent = observer(({ someComputed }: { someComputed: IComputedValue
expect(observedValue).toBe("some-pending-value");
});
const scenarioName = scenarioIsAsync
? "when admin messages propagate"
: "immediately";
const scenarioName = scenarioIsAsync ? "when admin messages propagate" : "immediately";
// eslint-disable-next-line jest/valid-title
describe(scenarioName, () => {
@@ -345,9 +320,7 @@ const TestComponent = observer(({ someComputed }: { someComputed: IComputedValue
expect(observedValue).toBe("some-pending-value");
});
const scenarioTitle = scenarioIsAsync
? "when value-messages propagate back"
: "immediately";
const scenarioTitle = scenarioIsAsync ? "when value-messages propagate back" : "immediately";
// eslint-disable-next-line jest/valid-title
describe(scenarioTitle, () => {
@@ -466,9 +439,7 @@ const TestComponent = observer(({ someComputed }: { someComputed: IComputedValue
expect(nonReactiveValue).toBe("some-initial-value");
});
const scenarioName = scenarioIsAsync
? "when messages would be propagated"
: "immediately";
const scenarioName = scenarioIsAsync ? "when messages would be propagated" : "immediately";
// eslint-disable-next-line jest/valid-title
describe(scenarioName, () => {
@@ -1,9 +1,6 @@
import ipcMainInjectable from "../ipc-main/ipc-main.injectable";
import type { IpcMain, IpcMainEvent } from "electron";
import {
EnlistMessageChannelListener,
enlistMessageChannelListenerInjectionToken,
} from "@k8slens/messaging";
import { EnlistMessageChannelListener, enlistMessageChannelListenerInjectionToken } from "@k8slens/messaging";
import { createContainer } from "@ogre-tools/injectable";
import { registerFeature } from "@k8slens/feature-core";
import { messagingFeatureForMain } from "../feature";
@@ -1,19 +1,13 @@
/* c8 ignore start */
import { getInjectable } from "@ogre-tools/injectable";
import {
RequestChannel,
RequestFromChannel,
requestFromChannelInjectionToken,
} from "@k8slens/messaging";
import { RequestChannel, RequestFromChannel, requestFromChannelInjectionToken } from "@k8slens/messaging";
const requestFromChannelInjectable = getInjectable({
id: "request-from-channel",
instantiate: () =>
((channel: RequestChannel<any, any>) => {
throw new Error(
`Tried to request from channel "${channel.id}" but requesting in "main" it's not supported yet`,
);
throw new Error(`Tried to request from channel "${channel.id}" but requesting in "main" it's not supported yet`);
}) as unknown as RequestFromChannel,
injectionToken: requestFromChannelInjectionToken,
@@ -1,9 +1,7 @@
import { getMessageChannel, getMessageChannelListenerInjectable } from "@k8slens/messaging";
import frameIdsInjectable from "./frameIds.injectable";
const frameCommunicationAdminChannel = getMessageChannel<undefined>(
"frame-communication-admin-channel",
);
const frameCommunicationAdminChannel = getMessageChannel<undefined>("frame-communication-admin-channel");
const allowCommunicationListenerInjectable = getMessageChannelListenerInjectable({
id: "allow-communication",
@@ -2,9 +2,7 @@ import { getInjectable } from "@ogre-tools/injectable";
import { onLoadOfApplicationInjectionToken } from "@k8slens/application";
import { getMessageChannel, sendMessageToChannelInjectionToken } from "@k8slens/messaging";
export const frameCommunicationAdminChannel = getMessageChannel<undefined>(
"frame-communication-admin-channel",
);
export const frameCommunicationAdminChannel = getMessageChannel<undefined>("frame-communication-admin-channel");
const allowCommunicationToIframeInjectable = getInjectable({
id: "allow-communication-to-iframe-injectable",
@@ -1,9 +1,6 @@
import type { IpcRendererEvent, IpcRenderer } from "electron";
import ipcRendererInjectable from "../ipc/ipc-renderer.injectable";
import {
EnlistMessageChannelListener,
enlistMessageChannelListenerInjectionToken,
} from "@k8slens/messaging";
import { EnlistMessageChannelListener, enlistMessageChannelListenerInjectionToken } from "@k8slens/messaging";
import { createContainer } from "@ogre-tools/injectable";
import { registerFeature } from "@k8slens/feature-core";
import { messagingFeatureForRenderer } from "../feature";
@@ -32,9 +32,7 @@ const someRequestChannelWithoutListeners: SomeRequestChannel = {
};
[{ scenarioIsAsync: true }, { scenarioIsAsync: false }].forEach(({ scenarioIsAsync }) =>
describe(`get-message-bridge-fake, given running as ${
scenarioIsAsync ? "async" : "sync"
}`, () => {
describe(`get-message-bridge-fake, given running as ${scenarioIsAsync ? "async" : "sync"}`, () => {
let messageBridgeFake: any;
beforeEach(() => {
@@ -135,9 +133,7 @@ const someRequestChannelWithoutListeners: SomeRequestChannel = {
describe("given a message is sent in di-1", () => {
beforeEach(() => {
const sendMessageToChannelFromDi1 = someDi1.inject(
sendMessageToChannelInjectionToken,
);
const sendMessageToChannelFromDi1 = someDi1.inject(sendMessageToChannelInjectionToken);
sendMessageToChannelFromDi1(someMessageChannel, "some-message");
});
@@ -161,13 +157,10 @@ const someRequestChannelWithoutListeners: SomeRequestChannel = {
});
it("the response gets handled in di-1", () => {
expect(someHandler1MockInDi1).toHaveBeenCalledWith(
"some-response-to: some-message",
{
frameId: 42,
processId: 42,
},
);
expect(someHandler1MockInDi1).toHaveBeenCalledWith("some-response-to: some-message", {
frameId: 42,
processId: 42,
});
});
scenarioIsAsync &&
@@ -191,13 +184,10 @@ const someRequestChannelWithoutListeners: SomeRequestChannel = {
});
it("the response gets handled in di-1", () => {
expect(someHandler1MockInDi1).toHaveBeenCalledWith(
"some-response-to: some-message",
{
frameId: 42,
processId: 42,
},
);
expect(someHandler1MockInDi1).toHaveBeenCalledWith("some-response-to: some-message", {
frameId: 42,
processId: 42,
});
});
});
});
@@ -375,9 +365,7 @@ const someRequestChannelWithoutListeners: SomeRequestChannel = {
const requestFromChannelFromDi2 = someDi2.inject(requestFromChannelInjectionToken);
return expect(() =>
requestFromChannelFromDi2(someRequestChannel, "irrelevant"),
).rejects.toThrow(
return expect(() => requestFromChannelFromDi2(someRequestChannel, "irrelevant")).rejects.toThrow(
'Tried to make a request but multiple listeners were discovered for channel "some-request-channel" in multiple DIs.',
);
});
@@ -385,9 +373,7 @@ const someRequestChannelWithoutListeners: SomeRequestChannel = {
it("when requesting from channel without listener, throws", () => {
const requestFromChannel = someDi1.inject(requestFromChannelInjectionToken);
return expect(() =>
requestFromChannel(someRequestChannelWithoutListeners, "irrelevant"),
).rejects.toThrow(
return expect(() => requestFromChannel(someRequestChannelWithoutListeners, "irrelevant")).rejects.toThrow(
'Tried to make a request but no listeners for channel "some-request-channel-without-listeners" was discovered in any DIs',
);
});
@@ -22,7 +22,7 @@ import asyncFn, { AsyncFnMock } from "@async-fn/jest";
export type MessageBridgeFake = {
involve: (...dis: DiContainer[]) => void;
messagePropagation: () => Promise<void>;
messagePropagationRecursive: (callback: any) => any;
messagePropagationRecursive: (callback: () => any) => any;
setAsync: (value: boolean) => void;
};
@@ -167,9 +167,7 @@ export const getMessageBridgeFake = (): MessageBridgeFake => {
await Promise.all(oldMessages.map((x) => wrapper(x.resolve)));
};
const messagePropagationRecursive = async (
wrapper: (callback: any) => any = (callback) => callback(),
) => {
const messagePropagationRecursive = async (wrapper = (callback: () => any) => callback()) => {
while (messagePropagationBuffer.size) {
await messagePropagation(wrapper);
}
@@ -27,9 +27,7 @@ const render = (components: ReactApplicationHigherOrderComponent[]) => {
export const ReactApplication = observer(({ di }: ReactApplicationProps) => {
const computedInjectMany = di.inject(computedInjectManyInjectable);
const higherOrderComponents = computedInjectMany(
reactApplicationHigherOrderComponentInjectionToken,
);
const higherOrderComponents = computedInjectMany(reactApplicationHigherOrderComponentInjectionToken);
const Components = [...higherOrderComponents.get(), ReactApplicationContent];