28 lines
689 B
JavaScript
28 lines
689 B
JavaScript
import { test, expect } from 'vitest';
|
|
|
|
import { Updux } from '../src/index.js';
|
|
|
|
test( 'selectors', () => {
|
|
const dux = new Updux({
|
|
initial: { a: 1, b: 2 },
|
|
selectors: {
|
|
getA: ({a}) => a,
|
|
getBPlus: ({b}) => addition => b + addition,
|
|
},
|
|
subduxes: {
|
|
subbie: new Updux({
|
|
initial: { d: 3 },
|
|
selectors: {
|
|
getD: ({d}) => d
|
|
}
|
|
})
|
|
}
|
|
})
|
|
|
|
const store = dux.createStore();
|
|
|
|
expect( store.getState.getA() ).toEqual(1);
|
|
expect( store.getState.getBPlus(7) ).toEqual(9);
|
|
expect( store.getState.getD() ).toEqual(3);
|
|
} );
|