47 lines
831 B
JavaScript
47 lines
831 B
JavaScript
import { test, expect } from 'vitest';
|
|
|
|
import { Updux } from './Updux.js';
|
|
|
|
const bar = new Updux({ initial: 123 });
|
|
|
|
const foo = new Updux({
|
|
initial: { root: 'abc' },
|
|
subduxes: {
|
|
bar,
|
|
},
|
|
});
|
|
|
|
test('single dux', () => {
|
|
const foo = new Updux({
|
|
initial: { a: 1 },
|
|
});
|
|
|
|
expect(foo.initial).toEqual({ a: 1 });
|
|
});
|
|
|
|
test('initial value', () => {
|
|
expect(foo.initial).toEqual({
|
|
root: 'abc',
|
|
bar: 123,
|
|
});
|
|
});
|
|
|
|
test('splat initial', async () => {
|
|
const bar = new Updux({
|
|
initial: { id: 0 },
|
|
});
|
|
|
|
const foo = new Updux({
|
|
subduxes: { '*': bar },
|
|
});
|
|
|
|
expect(foo.initial).toEqual([]);
|
|
|
|
expect(
|
|
new Updux({
|
|
initial: 'overriden',
|
|
subduxes: { '*': bar },
|
|
}).initial,
|
|
).toEqual('overriden');
|
|
});
|