Skip to content
Snippets Groups Projects
Commit dfb3d2db authored by Fernando Erd's avatar Fernando Erd :ok_hand:
Browse files

IDHMR route test

parent 67a1d4ca
No related branches found
No related tags found
2 merge requests!116Release v1.0.0,!60IDHMR and IDHM routes
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 idhmr', () => {
it('should list the year range', (done) => {
chai.request(server)
.get('/api/v1/idhmr/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 idhmr with valid filters', (done) => {
chai.request(server)
.get('/api/v1/idhmr?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 idhmr with invalid filters', (done) => {
chai.request(server)
.get('/api/v1/idhmr?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/idhmr')
.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