1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/common/__tests__/event-bus.test.ts
Sebastian Malton a51a4e75f2 Remove all global uses of AppEventBus
Signed-off-by: Sebastian Malton <sebastian@malton.name>
2022-07-20 09:46:54 -04:00

33 lines
889 B
TypeScript

/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import type { AppEvent } from "../app-event-bus/event-bus";
import { getDiForUnitTesting } from "../../main/getDiForUnitTesting";
import appEventBusInjectable from "../app-event-bus/app-event-bus.injectable";
import type { EventEmitter } from "../event-emitter";
describe("event bus tests", () => {
let appEventBus: EventEmitter<[AppEvent]>;
beforeEach(() => {
const di = getDiForUnitTesting();
appEventBus = di.inject(appEventBusInjectable);
});
describe("emit", () => {
it("emits an event", () => {
let event!: AppEvent;
appEventBus.addListener((data) => {
event = data;
});
appEventBus.emit({ name: "foo", action: "bar" });
expect(event.name).toBe("foo");
});
});
});