Git Repository Public Repository

YouAndWeb_TwoToc

URLs

Copy to Clipboard
 
a2ecfb85282bb782ae96a40499c728d5c266f710
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
'use strict';

var app = require('../..');
var request = require('supertest');

var newShow;

describe('Show API:', function() {

  describe('GET /api/shows', function() {
    var shows;

    beforeEach(function(done) {
      request(app)
        .get('/api/shows')
        .expect(200)
        .expect('Content-Type', /json/)
        .end(function(err, res) {
          if (err) {
            return done(err);
          }
          shows = res.body;
          done();
        });
    });

    it('should respond with JSON array', function() {
      shows.should.be.instanceOf(Array);
    });

  });

  describe('POST /api/shows', function() {
    beforeEach(function(done) {
      request(app)
        .post('/api/shows')
        .send({
          name: 'New Show',
          info: 'This is the brand new show!!!'
        })
        .expect(201)
        .expect('Content-Type', /json/)
        .end(function(err, res) {
          if (err) {
            return done(err);
          }
          newShow = res.body;
          done();
        });
    });

    it('should respond with the newly created show', function() {
      newShow.name.should.equal('New Show');
      newShow.info.should.equal('This is the brand new show!!!');
    });

  });

  describe('GET /api/shows/:id', function() {
    var show;

    beforeEach(function(done) {
      request(app)
        .get('/api/shows/' + newShow._id)
        .expect(200)
        .expect('Content-Type', /json/)
        .end(function(err, res) {
          if (err) {
            return done(err);
          }
          show = res.body;
          done();
        });
    });

    afterEach(function() {
      show = {};
    });

    it('should respond with the requested show', function() {
      show.name.should.equal('New Show');
      show.info.should.equal('This is the brand new show!!!');
    });

  });

  describe('PUT /api/shows/:id', function() {
    var updatedShow

    beforeEach(function(done) {
      request(app)
        .put('/api/shows/' + newShow._id)
        .send({
          name: 'Updated Show',
          info: 'This is the updated show!!!'
        })
        .expect(200)
        .expect('Content-Type', /json/)
        .end(function(err, res) {
          if (err) {
            return done(err);
          }
          updatedShow = res.body;
          done();
        });
    });

    afterEach(function() {
      updatedShow = {};
    });

    it('should respond with the updated show', function() {
      updatedShow.name.should.equal('Updated Show');
      updatedShow.info.should.equal('This is the updated show!!!');
    });

  });

  describe('DELETE /api/shows/:id', function() {

    it('should respond with 204 on successful removal', function(done) {
      request(app)
        .delete('/api/shows/' + newShow._id)
        .expect(204)
        .end(function(err, res) {
          if (err) {
            return done(err);
          }
          done();
        });
    });

    it('should respond with 404 when show does not exist', function(done) {
      request(app)
        .delete('/api/shows/' + newShow._id)
        .expect(404)
        .end(function(err, res) {
          if (err) {
            return done(err);
          }
          done();
        });
    });

  });

});

Commits for YouAndWeb_TwoTocserver/api/show/show.integration.js

Diff revisions: vs.
Revision Author Commited Message
a2ecfb ... PTKDev Fri 20 Nov, 2015 11:22:35 +0000

TwoToc code