Its expected behavior, since the two instances of the object in JavaScript do not match.
function Money(amount, currency){ this.amount = amount; this.currency = currency; this.sum = function (money){ return new Money(200, "USD"); } } var a = new Money(200, "USD") var b = a.sum(); console.log(a == b)
For a clean test, you should write your own interlocutor that compares amount and currency :
beforeEach(function() { this.addMatchers({ sameAmountOfMoney: function(expected) { return this.actual.currency == expected.currency && this.actual.amount == expected.amount; } }); });
Andreas Köberle May 6 '13 at 19:36 2013-05-06 19:36
source share