I am using Mocha and Chai to test my code. I have three assertions the first two pass fine but my PUT assertion is failing with an "Uncaught AssertionError: {message:"success" } to have property "name". The structure is the same for the previous tests but this one fails. Here is the test code: More eyes on this would be appreciated since I cannot seem to sort it out:
it("should edit an item on PUT", function (done) {
chai.request(app)
.put("/items/3")
.send({"name":"Kale Dog"})
.end(function (err, res) {
should.equal(err, null);
res.should.have.status(200);
res.should.be.json;
res.body.should.be.a("object");
res.body.should.have.property("name");
res.body.should.have.property("id");
res.body.name.should.be.a("string");
res.body.id.should.be.a("number");
res.body.name.should.be.equal("Kale Dog");
storage.items.should.be.a("array");
storage.items.should.have.length(3);
storage.items[3].should.be.a("object");
storage.items[3].should.have.property("name");
storage.items[3].should.have.property("id");
storage.items[3].id.should.be.a("number");
storage.items[3].name.should.be.a("string");
storage.items[3].name.should.equal("Kale Dog");
done();
});
});
Here is the actual error message:
Shopping List should edit an item on PUT:
Uncaught AssertionError: expected { message: 'success' } to have
property 'name'
Aucun commentaire:
Enregistrer un commentaire