-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
57 lines (53 loc) · 1.54 KB
/
test.js
File metadata and controls
57 lines (53 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
process.env.NODE_ENV = 'test';
const chai = require('chai');
const chaiHttp = require('chai-http');
const mongoose = require('mongoose');
const server = require('./index');
const booking = require('./server/models/bookings');
const { expect } = require('chai');
const should = chai.should();
chai.use(chaiHttp);
describe('booking', function() {
beforeEach(function(done) {
const newBooking = new booking({
movieTitle: 'Batman',
date: '2020-07-29',
time: '18:00',
customerName: 'Bob',
numberOfSeats: 1,
children: 0,
adults: 1,
concessions: 0
});
newBooking.save(function(err) {
done();
});
});
afterEach(function(){
return booking.collection.drop();
});
it('should add a SINGLE booking on /bookings POST', function(done) {
chai.request(server)
.post('/cinema/bookings')
.send({
'movieTitle': 'Batman',
'date': '2020-07-29',
'time': '18:00',
'customerName': 'Bob',
'numberOfSeats': 1,
'children': 0,
'adults': 1,
'concessions': 0
})
.end(function(err, res){
console.log(err);
console.log(res.body)
res.should.have.status(201);
res.should.be.json;
res.body.should.be.a('object');
res.body.should.have.property('success');
res.body.success.should.be.a('boolean');
done();
})
})
});