repos / starfx

a micro-mvc framework for react apps
git clone https://github.com/neurosnap/starfx.git

starfx / src / test
Vlad  ·  2025-06-15

action.test.ts

 1import { createAction } from "../index.js";
 2import { expect, test } from "../test.js";
 3
 4test("should return action type when stringified", () => {
 5  const undo = createAction("UNDO");
 6  expect("UNDO").toEqual(`${undo}`);
 7});
 8
 9test("return object with type", () => {
10  const undo = createAction("UNDO");
11  expect(undo()).toEqual({ type: "UNDO", payload: undefined });
12});
13
14test("createAction with object type should be compatible with UnknownAction", () => {
15  expect.assertions(1);
16  const emptyAction = createAction<object>("EMPTY_ACTION");
17  const action = emptyAction({});
18
19  // This should compile without TypeScript errors - testing the index signature
20  const hasIndexSignature = (action as any).someRandomProperty === undefined;
21  expect(hasIndexSignature).toBe(true);
22});