From d4d8bea5cf62de835354415a60c3439df930d383 Mon Sep 17 00:00:00 2001 From: Fernando Erd <fce15@inf.ufpr.br> Date: Tue, 14 Nov 2017 11:01:14 -0200 Subject: [PATCH] Add some tests --- src/test/enrollment.js | 13 ++++ src/test/infrastructure.js | 122 +++++++++++++++++++++++++++++++++++++ src/test/teacher.js | 13 ++++ 3 files changed, 148 insertions(+) create mode 100644 src/test/infrastructure.js diff --git a/src/test/enrollment.js b/src/test/enrollment.js index 2d35c63a..1ca9fac5 100644 --- a/src/test/enrollment.js +++ b/src/test/enrollment.js @@ -51,6 +51,19 @@ describe('request enrollments', () => { }); }); + it('should list the years', (done) => { + chai.request(server) + .get('/api/v1/enrollment/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('years'); + done(); + }); + }); + it('should list the locations', (done) => { chai.request(server) .get('/api/v1/enrollment/location') diff --git a/src/test/infrastructure.js b/src/test/infrastructure.js new file mode 100644 index 00000000..43b4a7c9 --- /dev/null +++ b/src/test/infrastructure.js @@ -0,0 +1,122 @@ +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 default query infrastructure', (done) => { + chai.request(server) + .get('/api/v1/infrastructure') + .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('school_place'); + done(); + }); + }); + + it('should list the year range', (done) => { + chai.request(server) + .get('/api/v1/infrastructure/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('years'); + done(); + }); + }); + + it('should list the source', (done) => { + chai.request(server) + .get('/api/v1/infrastructure/source') + .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('source'); + done(); + }); + }); + + it('should list the locations detailed', (done) => { + chai.request(server) + .get('/api/v1/infrastructure/location_detailed') + .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'); + done(); + }); + }); + + it('should list the locations', (done) => { + chai.request(server) + .get('/api/v1/infrastructure/location') + .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'); + done(); + }); + }); + + it('should list the source', (done) => { + chai.request(server) + .get('/api/v1/infrastructure/adm_dependency_detailed') + .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'); + done(); + }); + }); + + it('should list the source', (done) => { + chai.request(server) + .get('/api/v1/infrastructure/adm_dependency') + .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'); + done(); + }); + }); + +}); diff --git a/src/test/teacher.js b/src/test/teacher.js index 77cc39da..23d9eca6 100644 --- a/src/test/teacher.js +++ b/src/test/teacher.js @@ -65,6 +65,19 @@ describe('request teachers', () => { }); }); + it('should list the locations', (done) => { + chai.request(server) + .get('/api/v1/teacher/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('years'); + done(); + }); + }); + it('should list the rural locations', (done) => { chai.request(server) .get('/api/v1/teacher/rural_location') -- GitLab