Ellisande / mockolate

Simple mocking framework for JS
MIT License
1 stars 3 forks source link

Deep Equals Matcher #17

Open Ellisande opened 8 years ago

Ellisande commented 8 years ago

What kind of issue is this? (bug, feature, etc)

Feature

What is the proposed change?

Add a deep equal matcher for matching objects and arrays. Object

const a = {
  a: 1,
  b: 2
};
const b = {
  a: 1, 
  b: 2
};
a === b; //this is false
deepEquals(a).matches(b); //this should be true

Arrays

const a = [1, 2 ,3];
const b = [1, 2, 3];
a === b; //this is false;
deepEquals(a).matches(b); //this should be true

What was the old behavior, if any?

This matcher didn't exist, making it hard to test inputs that are derived object literals.

Why will this be beneficial?

It'll make it much easier to stub methods that are expecting objects or arrays as part of their arguments.

Misc. info

Chai already has an implementation of this in their code base somewhere, so feel free to borrow from them, or create one from scratch.

dbradf commented 7 years ago

Hi,

I put up a pull request to add this functionality.