Questions tagged «object-comparison»


5
在Jasmine中检查对象相等
Jasmine具有内置的MatcherstoBe和toEqual。如果我有这样的对象: function Money(amount, currency){ this.amount = amount; this.currency = currency; this.sum = function (money){ return new Money(200, "USD"); } } 并尝试与new Money(200, "USD")和的结果进行比较,这些内置匹配器将无法按预期工作。我已经设法实现了基于自定义equals方法和自定义匹配器的变通方法,但这似乎需要很多工作。 在Jasmine中比较对象的标准方法是什么?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.