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