From 59f80f7adb67b94d73868a14e1c7eebb8679c8cb Mon Sep 17 00:00:00 2001
From: Fernando Erd <fce15@inf.ufpr.br>
Date: Wed, 14 Mar 2018 09:53:51 -0300
Subject: [PATCH] Fix test in rate school

---
 src/test/rateSchool.js | 82 +++++++++++++++++++++++-------------------
 1 file changed, 45 insertions(+), 37 deletions(-)

diff --git a/src/test/rateSchool.js b/src/test/rateSchool.js
index 36ee35c4..b029fa42 100644
--- a/src/test/rateSchool.js
+++ b/src/test/rateSchool.js
@@ -24,17 +24,16 @@ const server = require(`${libs}/app`);
 
 chai.use(chaiHttp);
 describe('request rate_school', () => {
-    it('should list default query rate school', (done) => {
+    it('should return 400 with no filters', (done) => {
         chai.request(server)
             .get('/api/v1/rate_school')
             .end((err, res) => {
-                res.should.have.status(200);
+                res.should.have.status(400);
                 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.should.have.property('error');
+                res.body.error.should.be.equal('Wrong/No filter specified');
                 done();
-            });
+            })
     });
 
     it('should list the year range', (done) => {
@@ -133,106 +132,115 @@ describe('request rate_school', () => {
             });
     });
 
-    it('should list the fifth household income', (done) => {
+
+    it('should list the dimensions of ethnic groups', (done) => {
         chai.request(server)
-            .get('/api/v1/rate_school/fifth_household_income')
+            .get('/api/v1//rate_school?dims=ethnic_group_pnad&filter=min_year:"2015",max_year:"2015",age_range:["1"]')
             .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('ethnic_group_pnad_id');
+                res.body.result[0].should.have.property('ethnic_group_pnad_name');
+                res.body.result[0].should.have.property('year');
+                res.body.result[0].should.have.property('denominator');
+                res.body.result[0].should.have.property('partial');
                 done();
             });
     });
 
-    it('should list the extremes household income', (done) => {
+    it('should list the dimensions of gender', (done) => {
         chai.request(server)
-            .get('/api/v1/rate_school/extremes_household_income')
+            .get('/api/v1//rate_school?dims=gender&filter=min_year:"2015",max_year:"2015",age_range:["1"]')
             .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('gender_id');
+                res.body.result[0].should.have.property('gender_name');
+                res.body.result[0].should.have.property('year');
+                res.body.result[0].should.have.property('denominator');
+                res.body.result[0].should.have.property('partial');
                 done();
             });
     });
 
-    it('should list rate schools with dimension extremes household income', (done) => {
+    it('should list fifth household income', (done) => {
         chai.request(server)
-            .get('/api/v1/rate_school?dims=extremes_household_income')
+            .get('/api/v1//rate_school/fifth_household_income')
             .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('extremes_household_income_id');
-                res.body.result[0].should.have.property('total');
-                res.body.result[0].should.have.property('year');
-                res.body.result[0].should.have.property('partial');
-                res.body.result[0].should.have.property('denominator');
+                res.body.result[0].should.have.property('id');
+                res.body.result[0].should.have.property('name');
                 done();
             });
     });
 
-    it('should list rate schools with dimension fifth household income', (done) => {
+    it('should list the dimensions of fifth housebold income', (done) => {
         chai.request(server)
-            .get('/api/v1/rate_school?dims=fifth_household_income')
+            .get('/api/v1//rate_school?dims=fifth_household_income&filter=min_year:"2015",max_year:"2015",age_range:["1"]')
             .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('fifth_household_income_id');
-                res.body.result[0].should.have.property('total');
+                res.body.result[0].should.have.property('fifth_household_income_name');
                 res.body.result[0].should.have.property('year');
-                res.body.result[0].should.have.property('partial');
                 res.body.result[0].should.have.property('denominator');
+                res.body.result[0].should.have.property('partial');
+                res.body.result[0].should.have.property('total');
                 done();
             });
     });
 
-    it('should list rate schools with dimension fifth household income', (done) => {
+    it('should list extremes household income', (done) => {
         chai.request(server)
-            .get('/api/v1/rate_school?filter=region:[1,2],min_year:2015')
+            .get('/api/v1//rate_school/extremes_household_income')
             .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('partial');
-                res.body.result[0].should.have.property('denominator');
+                res.body.result[0].should.have.property('id');
+                res.body.result[0].should.have.property('name');
                 done();
             });
     });
 
-    it('should list the dimensions of ethnic groups', (done) => {
+    it('should list the dimensions of extremes housebold income', (done) => {
         chai.request(server)
-            .get('/api/v1/rate_school?dims=ethnic_group_pnad')
+            .get('/api/v1//rate_school?dims=extremes_household_income&filter=min_year:"2015",max_year:"2015",age_range:["1"]')
             .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('ethnic_group_pnad_id');
-                res.body.result[0].should.have.property('ethnic_group_pnad_name');
+                res.body.result[0].should.have.property('extremes_household_income_id');
+                res.body.result[0].should.have.property('extremes_household_income_name');
+                res.body.result[0].should.have.property('year');
+                res.body.result[0].should.have.property('denominator');
+                res.body.result[0].should.have.property('partial');
+                res.body.result[0].should.have.property('total');
                 done();
             });
     });
 
-    it('should list the dimensions of gender', (done) => {
+    it('should list year range', (done) => {
         chai.request(server)
-            .get('/api/v1/rate_school?dims=gender')
+            .get('/api/v1//rate_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('gender_pnad_id');
-                res.body.result[0].should.have.property('gender_pnad_name');
+                res.body.result[0].should.have.property('start_year');
+                res.body.result[0].should.have.property('end_year');
                 done();
             });
     });
-- 
GitLab