From 18ed61ba045d0d27d436aa76bb8a69c33ba1b4ec Mon Sep 17 00:00:00 2001 From: Lucas Gabriel Lima <lgl15@inf.ufpr.br> Date: Wed, 27 Jul 2016 09:26:20 -0300 Subject: [PATCH] add tests for requesting regions --- test/test.js | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/test/test.js b/test/test.js index 22bb6239..67c3337e 100644 --- a/test/test.js +++ b/test/test.js @@ -5,15 +5,9 @@ var expect = chai.expect; var should = chai.should(); //actually call the function var server = require('../libs/app'); -var foo = 'bar'; - - -it('doesn\'t do anything', function(){ - assert.typeOf(foo, 'string', 'foo is a string'); -}); +chai.use(chaiHttp); describe('request enrollments', function(){ - chai.use(chaiHttp); it('should list enrollments', function(done){ chai.request(server) @@ -24,6 +18,39 @@ describe('request enrollments', function(){ res.body.should.have.property('result'); res.body.result.should.be.a('array'); res.body.result[0].should.have.property('name'); + res.body.result[0].should.have.property('total'); + done(); + }) + }); +}); + +describe('request regions', function(){ + + it('should list all regions', function(done){ + chai.request(server) + .get('/v1/regions') + .end(function(err, res){ + res.should.have.status(200); + res.should.be.json; + res.body.should.have.property('result'); + res.body.result.should.be.a('array'); + res.body.result[0].should.have.property('pk_regiao_id'); + res.body.result[0].should.have.property('nome'); + done(); + }) + }); + + it('should list a especific region', function(done){ + chai.request(server) + .get('/v1/regions/1') + .end(function(err, res){ + res.should.have.status(200); + res.should.be.json; + res.body.should.have.property('result'); + res.body.result.should.be.a('array'); + res.body.result.should.have.length(1); + res.body.result[0].should.have.property('pk_regiao_id'); + res.body.result[0].should.have.property('nome'); done(); }) }); -- GitLab