Skip to content
Snippets Groups Projects
Commit 6e1112e7 authored by Rudolf Copi Eckelberg's avatar Rudolf Copi Eckelberg
Browse files

More simulation testing

parent 68b8c84c
No related branches found
No related tags found
2 merge requests!116Release v1.0.0,!25Auth
Pipeline #
...@@ -59,7 +59,7 @@ simulationApp.get('/:id', (req, res) => { ...@@ -59,7 +59,7 @@ simulationApp.get('/:id', (req, res) => {
if (!simulation) { if (!simulation) {
res.send({ success: false, msg: 'Entry not found' }); res.send({ success: false, msg: 'Entry not found' });
} else { } else {
res.send(JSON.stringify(simulation)); res.send(simulation);
} }
}); });
}); });
......
...@@ -16,6 +16,9 @@ const should = chai.should(); // actually call the function ...@@ -16,6 +16,9 @@ const should = chai.should(); // actually call the function
const server = require('../libs/app'); const server = require('../libs/app');
const mongoose = require('../libs/db/mongoose');
const Simulation = require('../libs/models/simulation');
chai.use(chaiHttp); chai.use(chaiHttp);
describe('request enrollments', () => { describe('request enrollments', () => {
...@@ -164,6 +167,12 @@ describe('request cities', () => { ...@@ -164,6 +167,12 @@ describe('request cities', () => {
}); });
describe('Create new sim', () => { describe('Create new sim', () => {
let newSimulation;
beforeEach(() => {
Simulation.remove();
});
it('should return a new simulation id', (done) => { it('should return a new simulation id', (done) => {
chai.request(server) chai.request(server)
.post('/api/v1/simulation') .post('/api/v1/simulation')
...@@ -178,4 +187,45 @@ describe('Create new sim', () => { ...@@ -178,4 +187,45 @@ describe('Create new sim', () => {
done(); done();
}); });
}); });
it('should find an existing simulation', (done) => {
newSimulation = new Simulation();
newSimulation.name = 'test';
newSimulation.save((err, sim) => {
let id = sim._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('_id');
res.body._id.should.be.a('string');
res.body.should.have.property('name');
res.body._id.should.be.a('string');
done();
});
});
});
it('should update an existing simulation', (done) => {
newSimulation = new Simulation();
newSimulation.name = 'test';
newSimulation.save((err, sim) => {
let id = sim._id;
chai.request(server)
.post(`/api/v1/simulation/${id}`)
.send({location: 5})
.end((err, res) => {
res.should.have.status(200);
res.should.be.json;
res.body.should.have.property('id');
res.body.id.should.be.a('string');
Simulation.findById(res.body.id, (err, simulation) => {
simulation.should.have.property('name');
simulation.name.should.be.a('string');
simulation.should.have.property('location');
simulation.location.should.be.a('number');
});
done();
});
});
});
}); });
{
"port": 3000,
"ip": "127.0.0.1",
"debug" : true,
"monetdb": {
"host": "simcaqdb1",
"port": 50000,
"dbname": "simcaq_dev",
"user": "monetdb",
"password":"monetdb",
"nrConnections": "16"
},
"mongodb" : {
"uri": "mongodb://localhost/test_users"
},
"default": {
"api": {
"version" : "v1"
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment