From 08ed3d406f178f372899fd76b982bf20597756c1 Mon Sep 17 00:00:00 2001 From: Asko Nõmm Date: Sat, 19 Apr 2025 18:49:32 +0300 Subject: Impl generics on dispatch/subscription arguments. --- src/shapex.test.ts | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'src/shapex.test.ts') diff --git a/src/shapex.test.ts b/src/shapex.test.ts index 35207bb..de40708 100644 --- a/src/shapex.test.ts +++ b/src/shapex.test.ts @@ -56,8 +56,13 @@ describe("dispatch", () => { const $ = ShapeX({ counter: 1 }); - // deno-lint-ignore no-unused-vars - const testEventCb: EventCallback = (state, arg1, arg2) => ({ + const testEventCb: EventCallback = ( + state, + // deno-lint-ignore no-unused-vars + arg1, + // deno-lint-ignore no-unused-vars + arg2 + ) => ({ state, }); @@ -67,11 +72,7 @@ describe("dispatch", () => { $.dispatch("test-event", "arg1-value", "arg2-value"); assertSpyCall(callback, 0, { - args: [ - { counter: 1 }, - "arg1-value", - "arg2-value", - ], + args: [{ counter: 1 }, "arg1-value", "arg2-value"], }); }); @@ -93,9 +94,7 @@ describe("dispatch", () => { $.dispatch("increment"); assertSpyCall(spyCb, 0, { - args: [ - { counter: 2 }, - ], + args: [{ counter: 2 }], }); }); @@ -136,9 +135,12 @@ describe("dispatch", () => { $.subscribe("parent-event", (state) => ({ state, - dispatch: [{ eventName: "nested-event-1" }, { - eventName: "nested-event-2", - }], + dispatch: [ + { eventName: "nested-event-1" }, + { + eventName: "nested-event-2", + }, + ], })); $.dispatch("parent-event"); @@ -154,7 +156,7 @@ describe("dispatch", () => { const $ = ShapeX({ counter: 1 }); // deno-lint-ignore no-unused-vars - const cb: EventCallback = (state, arg) => ({ state }); + const cb: EventCallback = (state, arg) => ({ state }); const spyCb = spy(cb); $.subscribe("nested-event", spyCb); @@ -368,10 +370,9 @@ describe("utility methods", () => { it("returns updated state", () => { const $ = ShapeX({ counter: 1 }); - $.subscribe( - "event1", - (state) => ({ state: { counter: state.counter + 1 } }), - ); + $.subscribe("event1", (state) => ({ + state: { counter: state.counter + 1 }, + })); $.dispatch("event1"); -- cgit v1.2.3