From fb19ba5ac7a62ec14adc0625c62d95758c6a8c55 Mon Sep 17 00:00:00 2001
From: Vytor Calixto <vytorcalixto@gmail.com>
Date: Wed, 18 Jan 2017 10:27:12 -0200
Subject: [PATCH] :white_check_mark: Adding tests in region, state and city for
 the search functionality

Related: simcaq/SCRUM#210 simcaq/simcaq-node!31
---
 src/test/city.js   | 14 ++++++++++++++
 src/test/region.js | 15 +++++++++++++++
 src/test/state.js  | 16 ++++++++++++++++
 3 files changed, 45 insertions(+)

diff --git a/src/test/city.js b/src/test/city.js
index 761bcb0e..ff8612fd 100644
--- a/src/test/city.js
+++ b/src/test/city.js
@@ -70,4 +70,18 @@ describe('request cities', () => {
                 done();
             })
     })
+
+    it('should search for Curitiba', (done) => {
+        chai.request(server)
+            .get('/api/v1/city?search=name:curitiba')
+            .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('pk_cod_ibge');
+                res.body.result[0].should.have.property('nome');
+                done();
+            });
+    });
 });
diff --git a/src/test/region.js b/src/test/region.js
index 12cf3d09..13e8316d 100644
--- a/src/test/region.js
+++ b/src/test/region.js
@@ -53,4 +53,19 @@ describe('request regions', () => {
                 done();
             });
     });
+
+    it('shoul search for south region', (done) => {
+        chai.request(server)
+            .get('/api/v1/region?search=name:sul')
+            .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.should.have.length(1);
+                res.body.result[0].should.have.property('pk_regiao_id');
+                res.body.result[0].should.have.property('nome');
+                done();
+            });
+    });
 });
diff --git a/src/test/state.js b/src/test/state.js
index d3794f98..c1b08f92 100644
--- a/src/test/state.js
+++ b/src/test/state.js
@@ -71,4 +71,20 @@ describe('request states', () => {
                 done();
             });
     });
+
+    it('should search for Paraná', (done) => {
+        chai.request(server)
+            .get('/api/v1/state?search=name:paran')
+            .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.should.have.length(1);
+                res.body.result[0].should.have.property('pk_estado_id');
+                res.body.result[0].should.have.property('fk_regiao_id');
+                res.body.result[0].should.have.property('nome');
+                done();
+            });
+    });
 });
-- 
GitLab