Jasmine has built-in matchers toBe
and toEqual
. If I have an object like this:
function Money(amount, currency){
this.amount = amou
Your problem is with truthyness. You are trying to compare two different instances of an object which is true for regular equality ( a == b ) but not true for strict equality ( a === b). The comparator that jasmine uses is jasmine.Env.equals_() which looks for strict equality.
To accomplish what you need without changing your code you can use the regular equality by checking for truthyness with something a little like the following:
expect(money1.sum() == money2.sum()).toBeTruthy();