import { test, expect } from 'vitest'; import Updux, { createAction, withPayload } from './index.js'; const incr = createAction('incr', withPayload()); const dux = new Updux({ initialState: 1, // selectors: { // double: (x: string) => x + x, // }, }).addMutation(incr, (i, action) => state => { expectTypeOf(i).toEqualTypeOf(); expectTypeOf(state).toEqualTypeOf(); expectTypeOf(action).toEqualTypeOf<{ type: 'incr', payload: number; }>(); return state + i }); suite.only('store dispatch actions', () => { const store = dux.createStore(); test('dispatch actions', () => { expect(store.dispatch.incr).toBeTypeOf('function'); expectTypeOf(store.dispatch.incr).toMatchTypeOf(); }); test('reducer does something', () => { store.dispatch.incr(7); expect(store.getState()).toEqual(8); }); });