Skip to content

Commit 076980f

Browse files
committed
test(core/plugins): prevent loading a same plugin twice
1 parent 97f37db commit 076980f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

core/plugins_test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,19 @@ describe("core/plugins", (test) => {
3030

3131
assertEquals(loaded, ["p1", "p2", "p3"]);
3232
});
33+
34+
test("do not load the same plugin twice", () => {
35+
const loaded: string[] = [];
36+
37+
const fakePlugin = (name: string, deps: Plugin<any, any>[] = []) =>
38+
createPlugin(name, deps)(() => loaded.push(name));
39+
40+
const p1 = fakePlugin("p1");
41+
const p2 = fakePlugin("p2");
42+
43+
const plugins: Plugin<any, any>[] = [p1, p1, p2];
44+
loadPlugins(null as unknown as CoreClient, {}, plugins);
45+
46+
assertEquals(loaded, ["p1", "p2"]);
47+
});
3348
});

0 commit comments

Comments
 (0)