29 lines
936 B
TypeScript
29 lines
936 B
TypeScript
import { describe, test, expect, mock } from "bun:test";
|
|
import { Eventra } from "@duxcore/eventra";
|
|
|
|
// We test the globalEvents module shape and the setupEventDebugger function.
|
|
// We import directly since the module has minimal side-effects.
|
|
import { events, setupEventDebugger } from "../../src/modules/globalEvents";
|
|
|
|
describe("globalEvents", () => {
|
|
test("events is an Eventra instance", () => {
|
|
expect(events).toBeDefined();
|
|
expect(typeof events.emit).toBe("function");
|
|
expect(typeof events.on).toBe("function");
|
|
});
|
|
|
|
test("setupEventDebugger registers a catch-all listener", () => {
|
|
// Calling setupEventDebugger should not throw
|
|
expect(() => setupEventDebugger()).not.toThrow();
|
|
});
|
|
|
|
test("can emit and receive events", () => {
|
|
let received = false;
|
|
events.on("api:started", () => {
|
|
received = true;
|
|
});
|
|
events.emit("api:started");
|
|
expect(received).toBe(true);
|
|
});
|
|
});
|