Add tests for null no-change and zero as real value
This commit is contained in:
@@ -45,3 +45,15 @@ test('mergeState does not mutate inputs', () => {
|
|||||||
assert.deepEqual(current, before);
|
assert.deepEqual(current, before);
|
||||||
assert.deepEqual(update, { title: 'X' });
|
assert.deepEqual(update, { title: 'X' });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('mergeState treats null fields as no-change', () => {
|
||||||
|
const current = { ...initialState, title: 'Previous' };
|
||||||
|
const next = mergeState(current, { title: null });
|
||||||
|
assert.equal(next.title, 'Previous');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('mergeState applies 0 as a real value (not a no-change)', () => {
|
||||||
|
const current = { ...initialState, progress: 42 };
|
||||||
|
const next = mergeState(current, { progress: 0 });
|
||||||
|
assert.equal(next.progress, 0);
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user