Skip to content

Commit 851f239

Browse files
committed
feat(vue): allow checking if echo is configured
1 parent fb3253e commit 851f239

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

packages/vue/src/config/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ const getEchoInstance = <T extends BroadcastDriver>(): Echo<T> => {
2323
return echoInstance as Echo<T>;
2424
};
2525

26+
export const isEchoConfigured = () => echoConfig !== null;
27+
2628
/**
2729
* Configure the Echo instance with sensible defaults.
2830
*

packages/vue/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ export {
55
useEchoPresence,
66
useEchoPublic,
77
} from "./composables/useEcho";
8-
export { configureEcho, echo } from "./config/index";
8+
export { configureEcho, echo, isEchoConfigured } from "./config/index";

packages/vue/tests/config.test.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
2-
import { configureEcho, echo } from "../src/config";
2+
33

44
describe("echo helper", async () => {
55
beforeEach(() => {
@@ -11,14 +11,30 @@ describe("echo helper", async () => {
1111
});
1212

1313
it("throws error when Echo is not configured", async () => {
14+
const { echo } = await import("../src/config");
15+
1416
expect(() => echo()).toThrow("Echo has not been configured");
1517
});
1618

1719
it("creates Echo instance with proper configuration", async () => {
20+
const { configureEcho, echo } = await import("../src/config");
21+
1822
configureEcho({
1923
broadcaster: "null",
2024
});
2125

2226
expect(echo()).toBeDefined();
2327
});
28+
29+
it("checks if Echo is configured", async () => {
30+
const { configureEcho, isEchoConfigured } = await import("../src/config");
31+
32+
expect(isEchoConfigured()).toBe(false);
33+
34+
configureEcho({
35+
broadcaster: "null",
36+
});
37+
38+
expect(isEchoConfigured()).toBe(true);
39+
});
2440
});

0 commit comments

Comments
 (0)