javascript - Can't get objects to be equal -
i'm getting following fail message mocha:
uncaught assertionerror: expected object { name: 'john doe' } object { name: 'john doe' } + expected - actual
here test code:
describe("a user gets registered", function () { it('should create single user on /api/register post', function (done) { //calling register api server .post('/api/register') .send({ name: "john doe", username: "john", password: "open" }) .expect("content-type", /json/) .expect(200) .end(function (err, res) { var data = { "name": "john doe" }; res.status.should.equal(200); res.body.should.equal(data); done(); }); }); });
and here actual code:
router.post('/', function (req, res) { var data = {name: 'john doe'}; res.status(200).json(data); }); module.exports = router;
however shouldn't fail message mocha, because both object equally same. somehow aren't don't know i'm doing wrong.
i have checked spacing of both objects shouldn't case.
2 objects cannot same though data same, because stored in memory 2 different enitities
var data = { name: 'piyush'}; var data1 = { name: 'piyush' }
data == data1 //false
Comments
Post a Comment