Skip to content

Commit e39b63d

Browse files
committed
Added path test for array values.
1 parent c866cb5 commit e39b63d

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/compare.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,30 @@ describe('Path comparisons', () => {
377377

378378
expect(comparePaths(obj1, obj2)).toStrictEqual([['flavours', '0']]);
379379
});
380+
381+
test('Paths with different array values', () => {
382+
/*
383+
Array comparisons can unfortunately break the illusion that the form
384+
fields themselves are tainted.
385+
If you click on a checkbox to add an item, the array comparison will
386+
taint more than one field.
387+
*/
388+
389+
const obj1 = {
390+
flavours: ['Mint choc chip'],
391+
scoops: 1
392+
};
393+
394+
const obj2 = {
395+
flavours: ['Cookies and cream', 'Mint choc chip'],
396+
scoops: 1
397+
};
398+
399+
expect(comparePaths(obj1, obj2)).toStrictEqual([
400+
['flavours', '0'],
401+
['flavours', '1']
402+
]);
403+
});
380404
});
381405

382406
test('Set paths', () => {

src/lib/client/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,8 +1393,6 @@ function formEnhance<T extends AnyZodObject, M>(
13931393

13941394
htmlForm.submitting();
13951395

1396-
// TODO: If SPA, cancel request here, factor out the result callback and call it directly.
1397-
13981396
if (options.SPA) {
13991397
cancel();
14001398

0 commit comments

Comments
 (0)