Reputation: 869
//spec
it('check process data to see if it returns correct JSON object', function() {
var dataExpected = [];
dataExpected.push({
image : "https://katmou.files.wordpress.com/2011/11/blade_runner.jpeg",
title : "Harrison",
id : 1
});
expect(dataAfter).toEqual(dataExpected);
});
error:
[ERROR] : . THERE WERE FAILURES!
[ERROR] : . ============================================================
[ERROR] : . Recap of failing specs:
[ERROR] : . ------------------------------------------------------------
[ERROR] : . viewP controller check process data to see if it returns correct JSON object. - Expected [ { image : 'https://katmou.files.wordpress.com/2011/11/blade_runner.jpeg', title : 'Harrison', id : '1' } ] to equal [ { image : 'https://katmou.files.wordpress.com/2011/11/blade_runner.jpeg', title : 'Harrison', id : 1 } ].
The data after is identical to what is expected and it is still failing, why?
Cheers.
Upvotes: 0
Views: 55
Reputation: 9323
You are expecting the id
property to be 1
, but in the results it is '1'
.
Upvotes: 1
Reputation: 1
As from the Jasmine 2.0 Doc http://jasmine.github.io/2.0/introduction.html the .toEqual
should work for object, but you are passing an array with one object, so it may be different.
Are you sure that dataAfter
is declared the same way?(an obj inside an array)
A different solution could be compare that two array passing them as string with JSON.stringify()
.
See: Object comparison in JavaScript
Upvotes: 0