Skip to content

toEqual Map/Set sort order with object keys/values #6138

Closed
@chrisblossom

Description

@chrisblossom

🐛 Bug Report

Set as an object and Map with an object key does not ignore sort order.

Relevant issues and PR: #4286 #4303 (comment)

To Reproduce

test('Map order does not matter with arrayed keys', () => {
    const example = new Map([
        [['one'], 1],
        [['two'], 2],
        [['three'], 3],
    ]);

    const expected = new Map([
        [['three'], 3],
        [['one'], 1],
        [['two'], 2],
    ]);

    expect(example).toEqual(expected);
});

test('Set order does not matter with arrays', () => {
    const example = new Set([
        ['one'],
        ['two'],
        ['three'],
    ]);

    const expected = new Set([
        ['three'],
        ['one'],
        ['two'],
    ]);

    expect(example).toEqual(expected);
});

Expected behavior

Sort order does not matter. Both above tests pass.

Link to repl or repo (highly encouraged)

https://github.com/chrisblossom/jest-issue-6138

Run npx envinfo --preset jest

Paste the results here:

  System:
    OS: macOS High Sierra 10.13.3
    CPU: x64 Intel(R) Core(TM) i7-4960HQ CPU @ 2.60GHz
  Binaries:
    Node: 8.9.4 - ~/.nvm/versions/node/v8.9.4/bin/node
    Yarn: 1.6.0 - ~/.yarn/bin/yarn
    npm: 5.6.0 - ~/.nvm/versions/node/v8.9.4/bin/npm
  npmPackages:
    jest: 22.4.3 => 22.4.3

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions