Skip to content
Snippets Groups Projects
Commit e6c24d65 authored by Vytor Calixto's avatar Vytor Calixto :space_invader:
Browse files

Add more test cases

parent 49c7842b
No related branches found
No related tags found
1 merge request!22Add istanbul to gulp task test
Pipeline #
...@@ -74,7 +74,7 @@ gulp.task('test', ['pre-test'], () => { ...@@ -74,7 +74,7 @@ gulp.task('test', ['pre-test'], () => {
gulp.src('test/test.js', {read: false}) gulp.src('test/test.js', {read: false})
.pipe(mocha()) .pipe(mocha())
.pipe(istanbul.writeReports()) .pipe(istanbul.writeReports())
.pipe(istanbul.enforceThresholds({ thresholds: { global: 90 } })) .pipe(istanbul.enforceThresholds({ thresholds: { global: 75 } }))
.once('error', () => { .once('error', () => {
process.exit(1); process.exit(1);
}) })
......
...@@ -37,8 +37,8 @@ schoolApp.get('/:id', (req, res, next) => { ...@@ -37,8 +37,8 @@ schoolApp.get('/:id', (req, res, next) => {
schoolApp.get('/state/:id', (req, res, next) => { schoolApp.get('/state/:id', (req, res, next) => {
req.sql.from('escolas') req.sql.from('escolas')
.field('pk_escola_id') .field('pk_escola_id')
.field('nome_entidade', 'name') .field('nome_entidade')
.field('ano_censo', 'year') .field('ano_censo')
.field('fk_cod_estado') .field('fk_cod_estado')
.field('fk_cod_municipio') .field('fk_cod_municipio')
.where('fk_cod_estado = ?', parseInt(req.params.id, 10)); .where('fk_cod_estado = ?', parseInt(req.params.id, 10));
...@@ -49,8 +49,8 @@ schoolApp.get('/state/:id', (req, res, next) => { ...@@ -49,8 +49,8 @@ schoolApp.get('/state/:id', (req, res, next) => {
schoolApp.get('/city/:id', (req, res, next) => { schoolApp.get('/city/:id', (req, res, next) => {
req.sql.from('escolas') req.sql.from('escolas')
.field('pk_escola_id') .field('pk_escola_id')
.field('nome_entidade', 'name') .field('nome_entidade')
.field('ano_censo', 'year') .field('ano_censo')
.field('fk_cod_estado') .field('fk_cod_estado')
.field('fk_cod_municipio') .field('fk_cod_municipio')
.where('fk_cod_municipio = ?', parseInt(req.params.id, 10)); .where('fk_cod_municipio = ?', parseInt(req.params.id, 10));
......
...@@ -18,6 +18,19 @@ const server = require(`${libs}/app`); ...@@ -18,6 +18,19 @@ const server = require(`${libs}/app`);
chai.use(chaiHttp); chai.use(chaiHttp);
describe('API is running', () => {
it('should respond it\'s running', (done) => {
chai.request(server)
.get('/api/v1')
.end((err, res) => {
res.should.have.status(200);
res.should.be.json;
res.body.should.have.property('msg');
done();
})
});
});
describe('request enrollments', () => { describe('request enrollments', () => {
it('should list enrollments', (done) => { it('should list enrollments', (done) => {
chai.request(server) chai.request(server)
...@@ -161,4 +174,68 @@ describe('request cities', () => { ...@@ -161,4 +174,68 @@ describe('request cities', () => {
done(); done();
}); });
}); });
it('should list all cities from a state', (done) => {
chai.request(server)
.get('/api/v1/city/state/41')
.end((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_municipio_id');
res.body.result[0].should.have.property('fk_estado_id');
res.body.result[0].should.have.property('nome');
res.body.result[0].should.have.property('codigo_ibge');
done();
})
})
});
describe('request schools', () => {
it('should list a school by id', (done) => {
chai.request(server)
.get('/api/v1/school/185588')
.end((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_escola_id');
res.body.result[0].should.have.property('ano_censo');
res.body.result[0].should.have.property('cod_entidade');
res.body.result[0].should.have.property('nome_entidade');
done();
});
});
it('should list all schools from a state', (done) => {
chai.request(server)
.get('/api/v1/school/state/41')
.end((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_escola_id');
res.body.result[0].should.have.property('ano_censo');
res.body.result[0].should.have.property('nome_entidade');
done();
});
});
it('should list all schools from a city', (done) => {
chai.request(server)
.get('/api/v1/school/city/3287')
.end((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_escola_id');
res.body.result[0].should.have.property('ano_censo');
res.body.result[0].should.have.property('nome_entidade');
done();
})
})
}); });
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment