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

Add test to some routes

parents 3dcc96fb bd02f312
No related branches found
No related tags found
No related merge requests found
Pipeline #
module.exports = function citySize(id) {
module.exports = function incomeLevel(id) {
switch (id) {
case 1:
return '1º quintil – 20% menores';
......
......@@ -38,6 +38,20 @@ describe('request class', () => {
});
});
it('should list the years', (done) => {
chai.request(server)
.get('/api/v1/class/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 the source', (done) => {
chai.request(server)
.get('/api/v1/class/source')
......
......@@ -44,9 +44,12 @@ describe('id2str middleware', () => {
});
it('should transform a location id', (done) => {
expect(id2str.location(6)).to.deep.equal('Unidade de uso sustentável');
expect(id2str.location(1)).to.deep.equal('Urbana');
expect(id2str.location(2)).to.deep.equal('Rural');
expect(id2str.location(3)).to.deep.equal('Área de assentamento');
expect(id2str.location(4)).to.deep.equal('Terra indígena');
expect(id2str.location(5)).to.deep.equal('Área remanescente de quilombos');
expect(id2str.location(6)).to.deep.equal('Unidade de uso sustentável');
done();
});
......@@ -58,25 +61,87 @@ describe('id2str middleware', () => {
it('should transform a income level id', (done) => {
expect(id2str.incomeLevel(1)).to.deep.equal('1º quintil – 20% menores');
expect(id2str.incomeLevel(12)).to.deep.equal('Não classificada');
done();
});
it('should transform a income level id', (done) => {
it('should transform a education level basic id', (done) => {
expect(id2str.educationLevelBasic(7)).to.deep.equal('Não classificada');
done();
});
it('should transform a class adm dependency id', (done) => {
it('should transform a age range id', (done) => {
expect(id2str.ageRange(12)).to.deep.equal('Não declarada');
done();
});
it('should transform a booleans variables', (done) => {
expect(id2str.booleanVariable(1)).to.deep.equal('Sim');
expect(id2str.booleanVariable(0)).to.deep.equal('Não');
expect(id2str.booleanVariable(null)).to.deep.equal('Não Declarado');
done();
});
it('should transform a city size id', (done) => {
expect(id2str.citySize(10)).to.deep.equal('Não classificada');
done();
});
it('should transform a educatoin type id', (done) => {
expect(id2str.educationType(10)).to.deep.equal('Não definido');
done();
});
it('should transform a gender Pnad id', (done) => {
expect(id2str.genderPnad(2)).to.deep.equal('Masculino');
expect(id2str.genderPnad(4)).to.deep.equal('Feminino');
done();
});
it('should transform a adm dependency id', (done) => {
expect(id2str.admDependency(6)).to.deep.equal('Não classificada');
done();
});
it('should transform a class adm dependency priv id', (done) => {
it('should transform a adm dependency priv id', (done) => {
expect(id2str.admDependencyPriv(7)).to.deep.equal('Não classificada');
done();
});
it('should transform a ethnic group id', (done) => {
expect(id2str.ethnicGroup(7)).to.deep.equal('Não declarada');
done();
});
it('should transform a ethnic group Pnad id', (done) => {
expect(id2str.ethnicGroupPnad(7)).to.deep.equal('Sem declaração');
done();
});
it('should transform a full age range id', (done) => {
expect(id2str.fullAgeRange(1)).to.deep.equal('0-3');
expect(id2str.fullAgeRange(2)).to.deep.equal('4-5');
expect(id2str.fullAgeRange(3)).to.deep.equal('6-10');
expect(id2str.fullAgeRange(4)).to.deep.equal('11-14');
expect(id2str.fullAgeRange(5)).to.deep.equal('15-17');
expect(id2str.fullAgeRange(6)).to.deep.equal('18-24');
expect(id2str.fullAgeRange(7)).to.deep.equal('25-29');
expect(id2str.fullAgeRange(8)).to.deep.equal('30-40');
expect(id2str.fullAgeRange(9)).to.deep.equal('41-50');
expect(id2str.fullAgeRange(10)).to.deep.equal('51-64');
expect(id2str.fullAgeRange(11)).to.deep.equal('64+');
expect(id2str.fullAgeRange(12)).to.deep.equal('Não declarada');
done();
});
it('should transform a idhm level id', (done) => {
expect(id2str.idhmLevel(12)).to.deep.equal('Não classificada');
done();
});
it('should transform a result', (done) => {
let req = {
result: [{gender_id: 2, period_id: 3, school_year_id: 11}]
......
......@@ -50,6 +50,20 @@ describe('request infrastructure', () => {
});
});
it('should list the years', (done) => {
chai.request(server)
.get('/api/v1/infrastructure/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 the source', (done) => {
chai.request(server)
.get('/api/v1/infrastructure/source')
......
......@@ -54,6 +54,21 @@ describe('request schools', () => {
});
});
it('should list a school by id', (done) => {
chai.request(server)
.get('/api/v1/school/education_end_elementary_school')
.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('id');
res.body.result[0].should.have.property('name');
//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?filter=state:41')
......@@ -84,6 +99,33 @@ describe('request schools', () => {
})
});
it('should list the year range', (done) => {
chai.request(server)
.get('/api/v1/school/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 the year range', (done) => {
chai.request(server)
.get('/api/v1/school/years')
.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('year');
done();
});
});
it('should return 400 with no filters', (done) => {
chai.request(server)
.get('/api/v1/school')
......
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