diff --git a/src/libs/convert/incomeLevel.js b/src/libs/convert/incomeLevel.js index c39106843027d91d628ec6bdda664507e660aae8..f80faf8692c93bee328e8051cb39ab5b05745deb 100644 --- a/src/libs/convert/incomeLevel.js +++ b/src/libs/convert/incomeLevel.js @@ -1,4 +1,4 @@ -module.exports = function citySize(id) { +module.exports = function incomeLevel(id) { switch (id) { case 1: return '1º quintil – 20% menores'; diff --git a/src/test/class.js b/src/test/class.js index ef5254f45d847a568c17b31afafc8119273cb50e..3000476ce8f5008dae9e9d8b51132a7512081a9d 100644 --- a/src/test/class.js +++ b/src/test/class.js @@ -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') diff --git a/src/test/id2str.js b/src/test/id2str.js index 1f4960c3e478ce3b2124cfe1a79d0bd195722a64..8d6f5457fac34c031612fd4cf8a9732a66690f67 100644 --- a/src/test/id2str.js +++ b/src/test/id2str.js @@ -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}] diff --git a/src/test/infrastructure.js b/src/test/infrastructure.js index c92fda1e1b4ae003beff20c202d852fa997eb115..8714a73cd12a73ba81652ff13a9f3feacc661dc9 100644 --- a/src/test/infrastructure.js +++ b/src/test/infrastructure.js @@ -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') diff --git a/src/test/school.js b/src/test/school.js index 266c542850095f1469d7952174af80e3a35d18e1..0ca4c78b47b93addb3aa5970588bfa1fc060d87f 100644 --- a/src/test/school.js +++ b/src/test/school.js @@ -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')