Skip to content
Snippets Groups Projects

Auth

Merged Lucas Gabriel Lima requested to merge auth into development
1 file
+ 37
5
Compare changes
  • Side-by-side
  • Inline
+ 37
5
@@ -166,14 +166,16 @@ describe('request cities', () => {
@@ -166,14 +166,16 @@ describe('request cities', () => {
});
});
});
});
describe('Create new sim', () => {
describe('Requires a simulation', () => {
let newSimulation;
let newSimulation;
beforeEach(() => {
beforeEach(() => {
Simulation.remove();
Simulation.remove({}, (err) => {
 
console.log('Test collection purged');
 
});
});
});
it('should return a new simulation id', (done) => {
it('should create a new simulation', (done) => {
chai.request(server)
chai.request(server)
.post('/api/v1/simulation')
.post('/api/v1/simulation')
.set('content-type', 'application/x-www-form-urlencoded')
.set('content-type', 'application/x-www-form-urlencoded')
@@ -184,6 +186,11 @@ describe('Create new sim', () => {
@@ -184,6 +186,11 @@ describe('Create new sim', () => {
res.should.be.json;
res.should.be.json;
res.body.should.have.property('id');
res.body.should.have.property('id');
res.body.id.should.be.a('string');
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.name.should.equal('test_entry');
 
});
done();
done();
});
});
});
});
@@ -205,14 +212,14 @@ describe('Create new sim', () => {
@@ -205,14 +212,14 @@ describe('Create new sim', () => {
});
});
});
});
});
});
it('should update an existing simulation', (done) => {
it('should update an existing simulation\'s location', (done) => {
newSimulation = new Simulation();
newSimulation = new Simulation();
newSimulation.name = 'test';
newSimulation.name = 'test';
newSimulation.save((err, sim) => {
newSimulation.save((err, sim) => {
let id = sim._id;
let id = sim._id;
chai.request(server)
chai.request(server)
.post(`/api/v1/simulation/${id}`)
.post(`/api/v1/simulation/${id}`)
.send({location: 5})
.send({ location: 5 })
.end((err, res) => {
.end((err, res) => {
res.should.have.status(200);
res.should.have.status(200);
res.should.be.json;
res.should.be.json;
@@ -223,6 +230,31 @@ describe('Create new sim', () => {
@@ -223,6 +230,31 @@ describe('Create new sim', () => {
simulation.name.should.be.a('string');
simulation.name.should.be.a('string');
simulation.should.have.property('location');
simulation.should.have.property('location');
simulation.location.should.be.a('number');
simulation.location.should.be.a('number');
 
simulation.location.should.equal(5);
 
});
 
done();
 
});
 
});
 
});
 
it('should update an existing simulation\'s time', (done) => {
 
newSimulation = new Simulation();
 
newSimulation.name = 'test';
 
newSimulation.save((err, sim) => {
 
let id = sim._id;
 
chai.request(server)
 
.post(`/api/v1/simulation/${id}`)
 
.send({ time: 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('time');
 
simulation.time.should.be.a('number');
 
simulation.time.should.equal(5);
});
});
done();
done();
});
});
Loading