我正在完成 AngularDart 教程,并在完成练习时尝试编写单元测试。
我有一个看起来像这样的测试:
test('should convert sugar ingredient to maple syrup', inject((SugarFilter filter) {
var r1 = new Recipe(null, null, null, ['has sugar in ingredients '], 'bla', null, null);
var r1New = new Recipe(null, null, null, ['has maple syrup in ingredient '], 'bla', null, null);
var r2 = new Recipe(null, null, null,[ 'has pure ingredients'], 'bla', null, null);
var inList = [r1, r2];
var outList = [r1New, r2];
expect(filter(inList), equals(outList));
}));
测试失败,输出如下:
Test failed: Caught Expected: [Instance of 'Recipe', Instance of 'Recipe']
Actual: [Instance of 'Recipe', Instance of 'Recipe']
Which: was <Instance of 'Recipe'> instead of <Instance of 'Recipe'> at location [0]
我尝试修改“categoryFilter”的现有测试以使其失败,并且得到相同但无用的输出。
有没有办法让两个对象的比较输出更有意义?