I'm testing a web applications' routers in Node.js using Mocha and I was wondering if there is a way to check in one single assert if an object has certain properties.
Right now, this is what I'm doing:
describe('GET /categories', function () {
it('should respond with 200 and return a list of categories', function (done) {
request.get('/categories')
.set('Authorization', 'Basic ' + new Buffer(tokenLogin).toString('base64'))
.expect('Content-Type', /json/)
.expect(200)
.end(function (err, res) {
if (err) return done(err);
expect(res.body).to.be.an.instanceof(Array);
expect(res.body).to.have.lengthOf.above(0);
expect(res.body[0]).to.have.property('id');
expect(res.body[0]).to.have.property('category');
expect(res.body[0]).to.have.property('tenant');
done();
});
});
});
I've searched in Mocha's documentation, but I haven't been able to find what I wanted.
Aucun commentaire:
Enregistrer un commentaire