... okay then

This commit is contained in:
Yanick Champoux 2023-09-07 10:21:11 -04:00
parent 8e16d9fef7
commit 8b88bcc0b2

32
src/subduxes.test.ts Normal file
View File

@ -0,0 +1,32 @@
import { test, expect } from 'vitest';
import { expectTypeOf } from 'expect-type';
import Updux from './Updux.js';
const subA = new Updux({
initialState: true,
actions: {
action1: (x: string) => x,
},
selectors: {
getAntiSub: (s) => !s,
},
});
const mainDux = new Updux({
subduxes: { subA },
});
test('subduxes resolves as objects', () => {
expectTypeOf(mainDux.initialState).toMatchTypeOf<{
subA: boolean;
}>();
expectTypeOf(mainDux.actions.action1('foo')).toMatchTypeOf<{
type: 'action1';
payload: string;
}>();
expectTypeOf(
mainDux.selectors.getAntiSub({ subA: true }),
).toMatchTypeOf<boolean>();
expect(mainDux.selectors.getAntiSub({ subA: true })).toEqual(false);
});