Skip to content

Commit

Permalink
Switch to lodash.isEqual for deep quality check (#1063)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadim Demedes authored and sindresorhus committed Oct 6, 2016
1 parent 446886e commit 8856684
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/assert.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
var util = require('util');
var assert = require('core-assert');
var deepEqual = require('not-so-shallow');
var deepEqual = require('lodash.isequal');
var observableToPromise = require('observable-to-promise');
var isObservable = require('is-observable');
var isPromise = require('is-promise');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,13 @@
"last-line-stream": "^1.0.0",
"lodash.debounce": "^4.0.3",
"lodash.difference": "^4.3.0",
"lodash.isequal": "^4.4.0",
"loud-rejection": "^1.2.0",
"matcher": "^0.1.1",
"max-timeout": "^1.0.0",
"md5-hex": "^1.2.0",
"meow": "^3.7.0",
"ms": "^0.7.1",
"not-so-shallow": "^0.1.3",
"object-assign": "^4.0.1",
"observable-to-promise": "^0.4.0",
"option-chain": "^0.1.0",
Expand Down
84 changes: 83 additions & 1 deletion test/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ test('.deepEqual()', function (t) {
assert.deepEqual(x, y);
});

t.doesNotThrow(function () {
t.throws(function () {
function Foo(a) {
this.a = a;
}
Expand Down Expand Up @@ -238,6 +238,88 @@ test('.deepEqual()', function (t) {
assert.deepEqual({0: 'a', 1: 'b'}, ['a', 'b']);
});

t.throws(function () {
assert.deepEqual({a: 1}, {a: 1, b: undefined});
});

t.throws(function () {
assert.deepEqual(new Date('1972-08-01'), null);
});

t.throws(function () {
assert.deepEqual(new Date('1972-08-01'), undefined);
});

t.doesNotThrow(function () {
assert.deepEqual(new Date('1972-08-01'), new Date('1972-08-01'));
});

t.doesNotThrow(function () {
assert.deepEqual({x: new Date('1972-08-01')}, {x: new Date('1972-08-01')});
});

t.throws(function () {
assert.deepEqual(function a() {}, function a() {});
});

t.doesNotThrow(function () {
assert.deepEqual(undefined, undefined);
assert.deepEqual({x: undefined}, {x: undefined});
assert.deepEqual({x: [undefined]}, {x: [undefined]});
});

t.doesNotThrow(function () {
assert.deepEqual(null, null);
assert.deepEqual({x: null}, {x: null});
assert.deepEqual({x: [null]}, {x: [null]});
});

t.doesNotThrow(function () {
assert.deepEqual(0, 0);
assert.deepEqual(1, 1);
assert.deepEqual(3.14, 3.14);
});

t.throws(function () {
assert.deepEqual(0, 1);
});

t.throws(function () {
assert.deepEqual(1, -1);
});

t.throws(function () {
assert.deepEqual(3.14, 2.72);
});

t.throws(function () {
assert.deepEqual({0: 'a', 1: 'b'}, ['a', 'b']);
});

t.doesNotThrow(function () {
assert.deepEqual(
[
{foo: {z: 100, y: 200, x: 300}},
'bar',
11,
{baz: {d: 4, a: 1, b: 2, c: 3}}
],
[
{foo: {x: 300, y: 200, z: 100}},
'bar',
11,
{baz: {c: 3, b: 2, a: 1, d: 4}}
]
);
});

t.doesNotThrow(function () {
assert.deepEqual(
{x: {a: 1, b: 2}, y: {c: 3, d: 4}},
{y: {d: 4, c: 3}, x: {b: 2, a: 1}}
);
});

// Regression test end here

t.doesNotThrow(function () {
Expand Down

0 comments on commit 8856684

Please sign in to comment.