Skip to content

Commit

Permalink
Fix bug in noDifferences function to ensure
Browse files Browse the repository at this point in the history
that lengths of array are equal.
  • Loading branch information
David Von Lehman committed Jul 16, 2015
1 parent 807617d commit 0aba472
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions index.js
Expand Up @@ -44,6 +44,9 @@ assert.noDifferences = function(array, otherArray) {
if (!(_.isArray(array) && _.isArray(otherArray)))
throw new Error("Both arguments must be arrays");

if (array.length !== otherArray.length)
throw new assert.AssertionError({message: "Arrays are not the same length"});

if (_.difference(array, otherArray).length > 0)
throw new assert.AssertionError({message: "Arrays have differences"});
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "dash-assert",
"version": "1.0.2",
"version": "1.0.3",
"description": "Assertion wrapper around lodash",
"main": "index.js",
"keywords": [
Expand Down
4 changes: 4 additions & 0 deletions test/assert.js
Expand Up @@ -63,6 +63,10 @@ describe('dash-assert', function() {
assert.throws(function() {
assert.noDifferences([1, 2, 3], [2, 3, 4]);
});

assert.throws(function() {
assert.noDifferences([], [1, 2, 3]);
});
});

it('hasIntersect', function() {
Expand Down

0 comments on commit 0aba472

Please sign in to comment.