3 var app = require('../..');
4 var request = require('supertest');
8 describe('Show API:', function() {
10 describe('GET /api/shows', function() {
13 beforeEach(function(done) {
17 .expect('Content-Type', /json/)
18 .end(function(err, res) {
27 it('should respond with JSON array', function() {
28 shows.should.be.instanceOf(Array);
33 describe('POST /api/shows', function() {
34 beforeEach(function(done) {
39 info: 'This is the brand new show!!!'
42 .expect('Content-Type', /json/)
43 .end(function(err, res) {
52 it('should respond with the newly created show', function() {
53 newShow.name.should.equal('New Show');
54 newShow.info.should.equal('This is the brand new show!!!');
59 describe('GET /api/shows/:id', function() {
62 beforeEach(function(done) {
64 .get('/api/shows/' + newShow._id)
66 .expect('Content-Type', /json/)
67 .end(function(err, res) {
76 afterEach(function() {
80 it('should respond with the requested show', function() {
81 show.name.should.equal('New Show');
82 show.info.should.equal('This is the brand new show!!!');
87 describe('PUT /api/shows/:id', function() {
90 beforeEach(function(done) {
92 .put('/api/shows/' + newShow._id)
95 info: 'This is the updated show!!!'
98 .expect('Content-Type', /json/)
99 .end(function(err, res) {
103 updatedShow = res.body;
108 afterEach(function() {
112 it('should respond with the updated show', function() {
113 updatedShow.name.should.equal('Updated Show');
114 updatedShow.info.should.equal('This is the updated show!!!');
119 describe('DELETE /api/shows/:id', function() {
121 it('should respond with 204 on successful removal', function(done) {
123 .delete('/api/shows/' + newShow._id)
125 .end(function(err, res) {
133 it('should respond with 404 when show does not exist', function(done) {
135 .delete('/api/shows/' + newShow._id)
137 .end(function(err, res) {