all action tests are done

main
Yanick Champoux 2023-03-06 16:07:22 -05:00
parent 000ca9871a
commit 88808507ad
3 changed files with 21 additions and 24 deletions

View File

@ -5,7 +5,12 @@ import {
DeepPartial,
Action,
} from 'redux';
import { configureStore, Reducer, createAction } from '@reduxjs/toolkit';
import {
configureStore,
Reducer,
createAction,
PrepareAction,
} from '@reduxjs/toolkit';
import { withPayload } from './actions.js';
import { AggregateActions, Dux, UnionToIntersection } from './types.js';
import { buildActions } from './buildActions.js';

View File

@ -1,23 +0,0 @@
import { test, expect } from 'vitest';
import { action } from './actions.js';
import { Updux } from './Updux.js';
test('action definition shortcut', () => {
const foo = new Updux({
actions: {
foo: null,
bar: (x) => ({ x }),
},
});
expect(foo.actions.foo('hello')).toEqual({ type: 'foo', payload: 'hello' });
expect(foo.actions.bar('hello')).toEqual({
type: 'bar',
payload: { x: 'hello' },
});
});

View File

@ -100,3 +100,18 @@ test('throw if double action', () => {
}),
).toThrow(/action 'foo' defined both in subduxes 'gamma' and 'beta'/);
});
test.todo('action definition shortcut', () => {
const foo = new Updux({
actions: {
foo: undefined,
bar: (x) => ({ x }),
},
});
expect(foo.actions.foo('hello')).toEqual({ type: 'foo', payload: 'hello' });
expect(foo.actions.bar('hello')).toEqual({
type: 'bar',
payload: { x: 'hello' },
});
});