mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fixup
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
parent
8aab8c020b
commit
4d8c26d587
@ -22,7 +22,7 @@ import type { MessageChannel } from "../message/message-channel-listener-injecti
|
||||
import { getMessageChannelListenerInjectable } from "../message/message-channel-listener-injection-token";
|
||||
import { registerMobX } from "@ogre-tools/injectable-extension-for-mobx";
|
||||
import { registerFeature } from "@k8slens/feature-core";
|
||||
import { messagingFeature } from "../feature";
|
||||
import { messagingFeatureForUnitTesting } from "../../unit-testing";
|
||||
import {
|
||||
computedChannelAdministrationChannel,
|
||||
ComputedChannelAdminMessage,
|
||||
@ -77,8 +77,8 @@ const testChannel2: MessageChannel<string> = { id: "some-other-channel-id" };
|
||||
});
|
||||
|
||||
runInAction(() => {
|
||||
registerFeature(di1, messagingFeature);
|
||||
registerFeature(di2, messagingFeature);
|
||||
registerFeature(di1, messagingFeatureForUnitTesting);
|
||||
registerFeature(di2, messagingFeatureForUnitTesting);
|
||||
|
||||
di1.register(channelValueTestListenerInjectable);
|
||||
di2.register(administrationChannelTestListenerInjectable);
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import {
|
||||
createContainer,
|
||||
DiContainer,
|
||||
getInjectable,
|
||||
Injectable,
|
||||
} from "@ogre-tools/injectable";
|
||||
|
||||
@ -14,7 +13,7 @@ import {
|
||||
enlistMessageChannelListenerInjectionToken,
|
||||
} from "./features/actual/message/enlist-message-channel-listener-injection-token";
|
||||
|
||||
import { messagingFeature } from "./features/actual/feature";
|
||||
import { messagingFeatureForUnitTesting } from "./features/unit-testing";
|
||||
|
||||
import {
|
||||
getMessageChannelListenerInjectable,
|
||||
@ -23,9 +22,9 @@ import {
|
||||
} from "./features/actual/message/message-channel-listener-injection-token";
|
||||
|
||||
import { listeningOfChannelsInjectionToken } from "./features/actual/listening-of-channels/listening-of-channels.injectable";
|
||||
import { enlistRequestChannelListenerInjectionToken } from "./features/actual/request/enlist-request-channel-listener-injection-token";
|
||||
import { sendMessageToChannelInjectionToken } from "./features/actual/message/message-to-channel-injection-token.no-coverage";
|
||||
|
||||
import { getMessageChannel } from "./features/actual/message/get-message-channel";
|
||||
import { applicationFeature, startApplicationInjectionToken } from "@k8slens/application";
|
||||
|
||||
describe("listening-of-messages", () => {
|
||||
let di: DiContainer;
|
||||
@ -42,38 +41,16 @@ describe("listening-of-messages", () => {
|
||||
disposeSomeUnrelatedListenerMock = jest.fn();
|
||||
|
||||
enlistMessageChannelListenerMock = jest.fn((listener) =>
|
||||
listener.id === "some-listener"
|
||||
listener.id === "some-channel-id-message-listener-some-listener"
|
||||
? disposeSomeListenerMock
|
||||
: disposeSomeUnrelatedListenerMock
|
||||
: disposeSomeUnrelatedListenerMock,
|
||||
);
|
||||
|
||||
const someEnlistMessageChannelListenerInjectable = getInjectable({
|
||||
id: "some-enlist-message-channel-listener",
|
||||
instantiate: () => enlistMessageChannelListenerMock,
|
||||
injectionToken: enlistMessageChannelListenerInjectionToken,
|
||||
});
|
||||
|
||||
const someEnlistRequestChannelListenerInjectable = getInjectable({
|
||||
id: "some-enlist-request-channel-listener",
|
||||
instantiate: () => () => () => {},
|
||||
injectionToken: enlistRequestChannelListenerInjectionToken,
|
||||
});
|
||||
|
||||
const sendMessageToChannelDummyInjectable = getInjectable({
|
||||
id: "send-message-to-channel-dummy",
|
||||
instantiate: () => () => {},
|
||||
injectionToken: sendMessageToChannelInjectionToken,
|
||||
});
|
||||
|
||||
runInAction(() => {
|
||||
di.register(
|
||||
someEnlistMessageChannelListenerInjectable,
|
||||
someEnlistRequestChannelListenerInjectable,
|
||||
sendMessageToChannelDummyInjectable
|
||||
);
|
||||
|
||||
registerFeature(di, messagingFeature);
|
||||
registerFeature(di, applicationFeature, messagingFeatureForUnitTesting);
|
||||
});
|
||||
|
||||
di.override(enlistMessageChannelListenerInjectionToken, () => enlistMessageChannelListenerMock);
|
||||
});
|
||||
|
||||
describe("given listening of channels has not started yet", () => {
|
||||
@ -102,19 +79,16 @@ describe("listening-of-messages", () => {
|
||||
});
|
||||
});
|
||||
|
||||
// Todo: make starting automatic by using a runnable with a timeslot.
|
||||
describe("when listening of channels is started", () => {
|
||||
beforeEach(() => {
|
||||
const listeningOnMessageChannels = di.inject(
|
||||
listeningOfChannelsInjectionToken
|
||||
);
|
||||
describe("when application is started", () => {
|
||||
beforeEach(async () => {
|
||||
const startApplication = di.inject(startApplicationInjectionToken);
|
||||
|
||||
listeningOnMessageChannels.start();
|
||||
await startApplication();
|
||||
});
|
||||
|
||||
it("it enlists a listener for the channel", () => {
|
||||
expect(enlistMessageChannelListenerMock).toHaveBeenCalledWith({
|
||||
id: "some-listener",
|
||||
id: "some-channel-id-message-listener-some-listener",
|
||||
channel: someChannel,
|
||||
handler: someMessageHandler,
|
||||
});
|
||||
@ -147,7 +121,7 @@ describe("listening-of-messages", () => {
|
||||
expect(enlistMessageChannelListenerMock.mock.calls).toEqual([
|
||||
[
|
||||
{
|
||||
id: "some-other-listener",
|
||||
id: "some-channel-id-message-listener-some-other-listener",
|
||||
channel: someChannel,
|
||||
handler: someMessageHandler,
|
||||
},
|
||||
|
||||
@ -1,9 +1,4 @@
|
||||
import {
|
||||
createContainer,
|
||||
DiContainer,
|
||||
getInjectable,
|
||||
Injectable,
|
||||
} from "@ogre-tools/injectable";
|
||||
import { createContainer, DiContainer, Injectable } from "@ogre-tools/injectable";
|
||||
|
||||
import { registerFeature } from "@k8slens/feature-core";
|
||||
import { registerMobX } from "@ogre-tools/injectable-extension-for-mobx";
|
||||
@ -14,7 +9,7 @@ import {
|
||||
enlistRequestChannelListenerInjectionToken,
|
||||
} from "./features/actual/request/enlist-request-channel-listener-injection-token";
|
||||
|
||||
import { messagingFeature } from "./features/actual/feature";
|
||||
import { messagingFeatureForUnitTesting } from "./features/unit-testing";
|
||||
|
||||
import {
|
||||
getRequestChannelListenerInjectable,
|
||||
@ -23,10 +18,9 @@ import {
|
||||
} from "./features/actual/request/request-channel-listener-injection-token";
|
||||
|
||||
import { listeningOfChannelsInjectionToken } from "./features/actual/listening-of-channels/listening-of-channels.injectable";
|
||||
import { enlistMessageChannelListenerInjectionToken } from "./features/actual/message/enlist-message-channel-listener-injection-token";
|
||||
import { noop } from "lodash/fp";
|
||||
import { sendMessageToChannelInjectionToken } from "./features/actual/message/message-to-channel-injection-token.no-coverage";
|
||||
import { getRequestChannel } from "./features/actual/request/get-request-channel";
|
||||
import { applicationFeature, startApplicationInjectionToken } from "@k8slens/application";
|
||||
|
||||
describe("listening-of-requests", () => {
|
||||
let di: DiContainer;
|
||||
@ -49,38 +43,16 @@ describe("listening-of-requests", () => {
|
||||
disposeSomeUnrelatedListenerMock = jest.fn();
|
||||
|
||||
enlistRequestChannelListenerMock = jest.fn((listener) =>
|
||||
listener.id === "some-listener"
|
||||
listener.id === "some-channel-id-request-listener-some-listener"
|
||||
? disposeSomeListenerMock
|
||||
: disposeSomeUnrelatedListenerMock
|
||||
: disposeSomeUnrelatedListenerMock,
|
||||
);
|
||||
|
||||
const someEnlistMessageChannelListenerInjectable = getInjectable({
|
||||
id: "some-enlist-message-channel-listener",
|
||||
instantiate: () => () => () => {},
|
||||
injectionToken: enlistMessageChannelListenerInjectionToken,
|
||||
});
|
||||
|
||||
const someEnlistRequestChannelListenerInjectable = getInjectable({
|
||||
id: "some-enlist-request-channel-listener",
|
||||
instantiate: () => enlistRequestChannelListenerMock,
|
||||
injectionToken: enlistRequestChannelListenerInjectionToken,
|
||||
});
|
||||
|
||||
const sendMessageToChannelDummyInjectable = getInjectable({
|
||||
id: "send-message-to-channel-dummy",
|
||||
instantiate: () => () => {},
|
||||
injectionToken: sendMessageToChannelInjectionToken,
|
||||
});
|
||||
|
||||
runInAction(() => {
|
||||
di.register(
|
||||
someEnlistMessageChannelListenerInjectable,
|
||||
someEnlistRequestChannelListenerInjectable,
|
||||
sendMessageToChannelDummyInjectable
|
||||
);
|
||||
|
||||
registerFeature(di, messagingFeature);
|
||||
registerFeature(di, applicationFeature, messagingFeatureForUnitTesting);
|
||||
});
|
||||
|
||||
di.override(enlistRequestChannelListenerInjectionToken, () => enlistRequestChannelListenerMock);
|
||||
});
|
||||
|
||||
describe("given listening of channels has not started yet", () => {
|
||||
@ -111,19 +83,16 @@ describe("listening-of-requests", () => {
|
||||
});
|
||||
});
|
||||
|
||||
// Todo: make starting automatic by using a runnable with a timeslot.
|
||||
describe("when listening of channels is started", () => {
|
||||
beforeEach(() => {
|
||||
const listeningOnRequestChannels = di.inject(
|
||||
listeningOfChannelsInjectionToken
|
||||
);
|
||||
describe("when application is started", () => {
|
||||
beforeEach(async () => {
|
||||
const startApplication = di.inject(startApplicationInjectionToken);
|
||||
|
||||
listeningOnRequestChannels.start();
|
||||
await startApplication();
|
||||
});
|
||||
|
||||
it("it enlists a listener for the channel", () => {
|
||||
expect(enlistRequestChannelListenerMock).toHaveBeenCalledWith({
|
||||
id: "some-listener",
|
||||
id: "some-channel-id-request-listener-some-listener",
|
||||
channel: someChannel,
|
||||
handler: someRequestHandler,
|
||||
});
|
||||
@ -142,8 +111,7 @@ describe("listening-of-requests", () => {
|
||||
|
||||
const handler = () => someRequestHandler;
|
||||
|
||||
const someConflictingListenerInjectable =
|
||||
getRequestChannelListenerInjectable({
|
||||
const someConflictingListenerInjectable = getRequestChannelListenerInjectable({
|
||||
id: "some-other-listener",
|
||||
channel: someChannel,
|
||||
getHandler: handler,
|
||||
@ -154,7 +122,7 @@ describe("listening-of-requests", () => {
|
||||
di.register(someConflictingListenerInjectable);
|
||||
});
|
||||
}).toThrow(
|
||||
'Tried to add listener for channel "some-channel-id" but listener already exists.'
|
||||
'Tried to add listener for channel "some-channel-id" but listener already exists.',
|
||||
);
|
||||
});
|
||||
|
||||
@ -184,7 +152,7 @@ describe("listening-of-requests", () => {
|
||||
expect(enlistRequestChannelListenerMock.mock.calls).toEqual([
|
||||
[
|
||||
{
|
||||
id: "some-other-listener",
|
||||
id: "some-other-channel-id-request-listener-some-other-listener",
|
||||
channel: someOtherChannel,
|
||||
handler: someRequestHandler,
|
||||
},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user