mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Simplify naming
Co-authored-by: Janne Savolainen <janne.savolainen@live.fi> Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>
This commit is contained in:
1 parent
5a1f5bde75
commit
4ae3a30c61
9 files changed
+41
-41
No files matched your search
@@ -6,8 +6,8 @@ import type { DiContainer } from "@ogre-tools/injectable";
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { LensWindow } from "../../main/start-main-application/lens-window/application-window/lens-window-injection-token";
|
||||
import { lensWindowInjectionToken } from "../../main/start-main-application/lens-window/application-window/lens-window-injection-token";
|
||||
import type { SendToAgnosticChannel } from "./send-to-agnostic-channel-injection-token";
|
||||
import { sendToAgnosticChannelInjectionToken } from "./send-to-agnostic-channel-injection-token";
|
||||
import type { SendToChannel } from "./send-to-channel-injection-token";
|
||||
import { sendToChannelInjectionToken } from "./send-to-channel-injection-token";
|
||||
import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
|
||||
import { channelListenerInjectionToken } from "./channel-listener-injection-token";
|
||||
import createLensWindowInjectable from "../../main/start-main-application/lens-window/application-window/create-lens-window.injectable";
|
||||
@@ -21,7 +21,7 @@ describe("channel", () => {
|
||||
let testChannel: TestChannel;
|
||||
let testListenerInWindowMock: jest.Mock;
|
||||
let mainDi: DiContainer;
|
||||
let sendToAgnosticChannel: SendToAgnosticChannel;
|
||||
let sendToChannel: SendToChannel;
|
||||
|
||||
beforeEach(async () => {
|
||||
const applicationBuilder = getApplicationBuilder();
|
||||
@@ -51,8 +51,8 @@ describe("channel", () => {
|
||||
|
||||
testChannel = mainDi.inject(testChannelInjectable);
|
||||
|
||||
sendToAgnosticChannel = mainDi.inject(
|
||||
sendToAgnosticChannelInjectionToken,
|
||||
sendToChannel = mainDi.inject(
|
||||
sendToChannelInjectionToken,
|
||||
);
|
||||
|
||||
await applicationBuilder.render();
|
||||
@@ -72,7 +72,7 @@ describe("channel", () => {
|
||||
});
|
||||
|
||||
it("when sending message, triggers listener in window", () => {
|
||||
sendToAgnosticChannel(testChannel, "some-message");
|
||||
sendToChannel(testChannel, "some-message");
|
||||
|
||||
expect(testListenerInWindowMock).toHaveBeenCalledWith("some-message");
|
||||
});
|
||||
@@ -80,7 +80,7 @@ describe("channel", () => {
|
||||
it("given window is hidden, when sending message, does not trigger listener in window", () => {
|
||||
someWindowFake.close();
|
||||
|
||||
sendToAgnosticChannel(testChannel, "some-message");
|
||||
sendToChannel(testChannel, "some-message");
|
||||
|
||||
expect(testListenerInWindowMock).not.toHaveBeenCalled();
|
||||
});
|
||||
@@ -93,7 +93,7 @@ describe("channel", () => {
|
||||
await someWindowFake.show();
|
||||
await someOtherWindowFake.show();
|
||||
|
||||
sendToAgnosticChannel(testChannel, "some-message");
|
||||
sendToChannel(testChannel, "some-message");
|
||||
|
||||
expect(testListenerInWindowMock.mock.calls).toEqual([
|
||||
["some-message"],
|
||||
@@ -107,7 +107,7 @@ describe("channel", () => {
|
||||
let testListenerInMainMock: jest.Mock;
|
||||
let rendererDi: DiContainer;
|
||||
let mainDi: DiContainer;
|
||||
let sendToAgnosticChannel: SendToAgnosticChannel;
|
||||
let sendToChannel: SendToChannel;
|
||||
|
||||
beforeEach(async () => {
|
||||
const applicationBuilder = getApplicationBuilder();
|
||||
@@ -137,15 +137,15 @@ describe("channel", () => {
|
||||
|
||||
testChannel = rendererDi.inject(testChannelInjectable);
|
||||
|
||||
sendToAgnosticChannel = rendererDi.inject(
|
||||
sendToAgnosticChannelInjectionToken,
|
||||
sendToChannel = rendererDi.inject(
|
||||
sendToChannelInjectionToken,
|
||||
);
|
||||
|
||||
await applicationBuilder.render();
|
||||
});
|
||||
|
||||
it("when sending message, triggers listener in main", () => {
|
||||
sendToAgnosticChannel(testChannel, "some-message");
|
||||
sendToChannel(testChannel, "some-message");
|
||||
|
||||
expect(testListenerInMainMock).toHaveBeenCalledWith("some-message");
|
||||
});
|
||||
|
||||
+4
-4
@@ -5,12 +5,12 @@
|
||||
import { getInjectionToken } from "@ogre-tools/injectable";
|
||||
import type { Channel } from "./channel-injection-token";
|
||||
|
||||
export type SendToAgnosticChannel = <TChannel extends Channel<unknown, unknown>>(
|
||||
export type SendToChannel = <TChannel extends Channel<unknown, unknown>>(
|
||||
channel: TChannel,
|
||||
message?: TChannel["_messageTemplate"]
|
||||
) => void;
|
||||
|
||||
export const sendToAgnosticChannelInjectionToken =
|
||||
getInjectionToken<SendToAgnosticChannel>({
|
||||
id: "send-to-agnostic-channel",
|
||||
export const sendToChannelInjectionToken =
|
||||
getInjectionToken<SendToChannel>({
|
||||
id: "send-to-channel",
|
||||
});
|
||||
@@ -5,7 +5,7 @@
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { computed } from "mobx";
|
||||
import syncBoxChannelInjectable from "./sync-box-channel.injectable";
|
||||
import { sendToAgnosticChannelInjectionToken } from "../channel/send-to-agnostic-channel-injection-token";
|
||||
import { sendToChannelInjectionToken } from "../channel/send-to-channel-injection-token";
|
||||
import syncBoxStateInjectable from "./sync-box-state.injectable";
|
||||
import type { SyncBox } from "./sync-box-injection-token";
|
||||
|
||||
@@ -14,7 +14,7 @@ const createSyncBoxInjectable = getInjectable({
|
||||
|
||||
instantiate: (di) => {
|
||||
const syncBoxChannel = di.inject(syncBoxChannelInjectable);
|
||||
const sendToAgnosticChannel = di.inject(sendToAgnosticChannelInjectionToken);
|
||||
const sendToChannel = di.inject(sendToChannelInjectionToken);
|
||||
const getSyncBoxState = (id: string) => di.inject(syncBoxStateInjectable, id);
|
||||
|
||||
return <TData>(id: string): SyncBox<TData> => {
|
||||
@@ -28,7 +28,7 @@ const createSyncBoxInjectable = getInjectable({
|
||||
set: (value) => {
|
||||
state.set(value);
|
||||
|
||||
sendToAgnosticChannel(syncBoxChannel, { id, value });
|
||||
sendToChannel(syncBoxChannel, { id, value });
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user