From fac5408225fc1bd73a10119c70e93aa355beae80 Mon Sep 17 00:00:00 2001
From: Rudolf Copi Eckelberg <rce16@inf.ufpr.br>
Date: Wed, 5 Oct 2016 09:56:39 -0300
Subject: [PATCH] Even more simulation tests

---
 src/test/test.js | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/src/test/test.js b/src/test/test.js
index 55d96515..e3f03fc2 100644
--- a/src/test/test.js
+++ b/src/test/test.js
@@ -194,6 +194,23 @@ describe('Requires a simulation', () => {
                 done();
             });
     });
+    it('should not create a nameless simulation', (done) => {
+        chai.request(server)
+            .post('/api/v1/simulation')
+            .set('content-type', 'application/x-www-form-urlencoded')
+            .set('x-apicache-bypass', 'true')
+            .end((err, res) => {
+                res.should.have.status(200);
+                res.should.be.json;
+                res.body.should.not.have.property('id');
+                res.body.should.have.property('success');
+                res.body.success.should.equal(false);
+                Simulation.findById(res.body.id, (err, simulation) => {
+                    expect(simulation).to.not.exist;
+                });
+                done();
+            });
+    });
     it('should find an existing simulation', (done) => {
         newSimulation = new Simulation();
         newSimulation.name = 'test';
@@ -212,6 +229,19 @@ describe('Requires a simulation', () => {
                 });
         });
     });
+    it('should not find an unexisting simulation', (done) => {
+        newSimulation = new Simulation();
+        let id = newSimulation._id;
+        chai.request(server)
+            .get(`/api/v1/simulation/${id}`)
+            .end((err, res) => {
+                res.should.have.status(200);
+                res.should.be.json;
+                res.body.should.have.property('success');
+                res.body.success.should.equal(false);
+                done();
+            });
+    });
     it('should update an existing simulation\'s location', (done) => {
         newSimulation = new Simulation();
         newSimulation.name = 'test';
-- 
GitLab