26 lines
839 B
JavaScript
26 lines
839 B
JavaScript
|
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();
|
||
|
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);
|
||
|
});
|
||
|
});
|