Skip to content
Snippets Groups Projects
Commit 50078834 authored by Gabriel Ruschel's avatar Gabriel Ruschel
Browse files

Add idhme route test

parent 06f017af
No related branches found
No related tags found
2 merge requests!116Release v1.0.0,!59Idhm e route
Pipeline #
process.env.NODE_ENV = 'test';
const chai = require('chai');
const dirtyChai = require('dirty-chai');
chai.use(dirtyChai);
const chaiXml = require('chai-xml');
chai.use(chaiXml);
const chaiHttp = require('chai-http');
const assert = chai.assert;
const expect = chai.expect;
const should = chai.should(); // actually call the function
const libs = `${process.cwd()}/libs`;
const server = require(`${libs}/app`);
chai.use(chaiHttp);
describe('request idhme', () => {
it('should list the year range', (done) => {
chai.request(server)
.get('/api/v1/idhme/year_range')
.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('start_year');
res.body.result[0].should.have.property('end_year');
done();
});
});
it('should list idhme with valid filters', (done) => {
chai.request(server)
.get('/api/v1/idhme?filter=min_year:2000,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('total');
res.body.result[0].should.have.property('year');
res.body.result[0].should.have.property('state_id');
done();
});
});
it('should list idhme with invalid filters', (done) => {
chai.request(server)
.get('/api/v1/idhme?filter=foo:2010,bar:41')
.end((err, res) => {
res.should.have.status(400);
res.should.be.json;
res.body.should.have.property('error');
res.body.error.should.be.equal('Wrong/No filter specified');
done();
});
});
it('should return 400 with no filters', (done) => {
chai.request(server)
.get('/api/v1/idhme')
.end((err, res) => {
res.should.have.status(400);
res.should.be.json;
res.body.should.have.property('error');
res.body.error.should.be.equal('Wrong/No filter specified');
done();
})
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment