Skip to content

ignoreArrayOrder: true + referenceProperty set should make superdiff disregard changes of position in arrays #22

Closed
@martinjo

Description

@martinjo

I was hoping to get this case to work:

describe('JSON Diff with Superdiff', () => {
const options = { referenceProperty: 'id', ignoreArrayOrder: false };

it('should ignore position changes in arrays', () => {
const original = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];
const updated = [{ id: 2, name: 'Bob' }, { id: 1, name: 'Alice' }];

const diff = getObjectDiff(original, updated, options);
expect(diff.status).toBe('equal');

});

But instead it will list both array items as updated. Is there a way to make superdiff disregard changes of items position in an array completely?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions