diff options
| author | Asko Nõmm <asko@nmm.ee> | 2025-04-20 18:49:27 +0300 |
|---|---|---|
| committer | Asko Nõmm <asko@nmm.ee> | 2025-04-20 18:49:27 +0300 |
| commit | 09783a86490a7fabb8ccdbd12238601fe4d951b8 (patch) | |
| tree | 3c2cad397e01c395a92b3f73da3a27cd2c71cb38 /src/shapex.test.ts | |
| parent | 5a46717e364f391b5fa775146620c2652960d70e (diff) | |
Closes #1
Diffstat (limited to 'src/shapex.test.ts')
| -rw-r--r-- | src/shapex.test.ts | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/shapex.test.ts b/src/shapex.test.ts index de40708..5c555b0 100644 --- a/src/shapex.test.ts +++ b/src/shapex.test.ts @@ -56,12 +56,10 @@ describe("dispatch", () => { const $ = ShapeX<AppState>({ counter: 1 }); - const testEventCb: EventCallback<AppState, [string, string]> = ( + const testEventCb: EventCallback<AppState, string> = ( state, // deno-lint-ignore no-unused-vars - arg1, - // deno-lint-ignore no-unused-vars - arg2 + data ) => ({ state, }); @@ -69,10 +67,10 @@ describe("dispatch", () => { const callback = spy(testEventCb); $.subscribe("test-event", callback); - $.dispatch("test-event", "arg1-value", "arg2-value"); + $.dispatch("test-event", "arg1-value"); assertSpyCall(callback, 0, { - args: [{ counter: 1 }, "arg1-value", "arg2-value"], + args: [{ counter: 1 }, "arg1-value"], }); }); @@ -111,7 +109,7 @@ describe("dispatch", () => { $.subscribe("parent-event", (state) => ({ state, - dispatch: { eventName: "nested-event" }, + dispatch: { to: "nested-event" }, })); $.dispatch("parent-event"); @@ -136,9 +134,9 @@ describe("dispatch", () => { $.subscribe("parent-event", (state) => ({ state, dispatch: [ - { eventName: "nested-event-1" }, + { to: "nested-event-1" }, { - eventName: "nested-event-2", + to: "nested-event-2", }, ], })); @@ -156,14 +154,14 @@ describe("dispatch", () => { const $ = ShapeX<AppState>({ counter: 1 }); // deno-lint-ignore no-unused-vars - const cb: EventCallback<AppState, [string]> = (state, arg) => ({ state }); + const cb: EventCallback<AppState, string> = (state, arg) => ({ state }); const spyCb = spy(cb); $.subscribe("nested-event", spyCb); $.subscribe("parent-event", (state) => ({ state, - dispatch: { eventName: "nested-event", args: ["arg-value"] }, + dispatch: { to: "nested-event", withData: "arg-value" }, })); $.dispatch("parent-event"); |
