Skip to content

Commit

Permalink
[Tests] add passing tests covering object key ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Feb 10, 2023
1 parent b9d9e54 commit 51c9ff6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/cmp.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var gOPDs = require('object.getownpropertydescriptors');
var hasSymbols = require('has-symbols')();
var hasTypedArrays = require('has-typed-arrays')();
var semver = require('semver');
var keys = require('object-keys');

var safeBuffer = typeof Buffer === 'function' ? Buffer.from && Buffer.from.length > 1 ? Buffer.from : Buffer : null;
var buffersAreTypedArrays = typeof Buffer === 'function' && new Buffer(0) instanceof Uint8Array;
Expand Down Expand Up @@ -35,6 +36,18 @@ test('equal', function (t) {
false
);

var obj1 = { a: [2, 3], b: [4] };
var obj2 = { b: [4], a: [2, 3] };
t.notDeepEqual(keys(obj1), keys(obj2), 'keys are in a different order');
t.deepEqual(keys(obj1), keys(obj2).reverse(), 'keys are in opposite order');
t.deepEqualTest(
obj1,
obj2,
'two equal objects, in different order',
true,
true
);

t.deepEqualTest(
{ a: 2, b: '4' },
{ a: 2, b: 4 },
Expand Down

0 comments on commit 51c9ff6

Please sign in to comment.