... okay then
This commit is contained in:
parent
8e16d9fef7
commit
8b88bcc0b2
32
src/subduxes.test.ts
Normal file
32
src/subduxes.test.ts
Normal 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);
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user