fix broken tests

This commit is contained in:
Chris Kruining 2025-02-04 16:49:13 +11:00
parent 99c2df1bfa
commit 57b10f8e96
No known key found for this signature in database
GPG key ID: EB894A3560CCCAD2
2 changed files with 6 additions and 2 deletions

View file

@ -22,7 +22,7 @@ describe('dataset', () => {
const actual = createDataSet(defaultData); const actual = createDataSet(defaultData);
// Assert // Assert
expect(actual).toMatchObject({ data: defaultData }) expect(actual).toMatchObject({ value: defaultData() })
}); });
it('can sort by a property', async () => { it('can sort by a property', async () => {
@ -46,7 +46,7 @@ describe('dataset', () => {
const actual = createDataSet(defaultData, { group: { by: 'name' } }); const actual = createDataSet(defaultData, { group: { by: 'name' } });
// Assert // Assert
expect(actual).toEqual(expect.objectContaining({ data: defaultData })) expect(actual).toEqual(expect.objectContaining({ value: defaultData() }))
}); });
describe('mutate', () => { describe('mutate', () => {

View file

@ -100,6 +100,8 @@ export const createDataSet = <T extends Record<string, any>>(data: Accessor<T[]>
}); });
const apply = (data: T[], mutations: Mutation[]) => { const apply = (data: T[], mutations: Mutation[]) => {
console.log('APPLY', data, mutations);
for (const mutation of mutations) { for (const mutation of mutations) {
const path = mutation.key.split('.'); const path = mutation.key.split('.');
@ -162,6 +164,8 @@ export const createDataSet = <T extends Record<string, any>>(data: Accessor<T[]>
const next = data(); const next = data();
const nextValue = apply(deepCopy(next), untrack(() => mutations())); const nextValue = apply(deepCopy(next), untrack(() => mutations()));
console.log('EFFECT IS CALLED');
setState('value', nextValue); setState('value', nextValue);
setState('snapshot', next); setState('snapshot', next);
}); });