Alternatively, this should work too:
res.body.should.have.property("name", "new_org");
Also, just a note but logically I think it makes sense to put this in another call to expects
instead of in the final callback. This function can also be re-used, so I tend to put it somewhere reusable when possible:
var isValidOrg = function(res) {
res.body.should.have.property("name", "new_org");
};
it("should create a new org with valid privileges and input with status 201", function(done) {
request(app)
.post("/orgs")
.send({ name: "new_org", owner: "oldschool@aol.com", timezone: "America/New_York", currency: "USD"})
.expect(201)
.expect(isValidOrg)
.end(done);
});
Now you could imagine you’re testing a GET
for /orgs/:orgId
and you could just re-use the same validation.