YouAndWeb_TwoToc
a98e8d4c8be3c9266abcdd007f47a6b1c3ed9599
YouAndWeb_TwoToc / .fr-KzWVa7 / twotoc / server / api / category / category.integration.js
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 newCategory; describe('Category API:', function() { describe('GET /api/categories', function() { var categorys; beforeEach(function(done) { request(app) .get('/api/categories') .expect(200) .expect('Content-Type', /json/) .end(function(err, res) { if (err) { return done(err); } categorys = res.body; done(); }); }); it('should respond with JSON array', function() { categorys.should.be.instanceOf(Array); }); }); describe('POST /api/categories', function() { beforeEach(function(done) { request(app) .post('/api/categories') .send({ name: 'New Category', info: 'This is the brand new category!!!' }) .expect(201) .expect('Content-Type', /json/) .end(function(err, res) { if (err) { return done(err); } newCategory = res.body; done(); }); }); it('should respond with the newly created category', function() { newCategory.name.should.equal('New Category'); newCategory.info.should.equal('This is the brand new category!!!'); }); }); describe('GET /api/categories/:id', function() { var category; beforeEach(function(done) { request(app) .get('/api/categories/' + newCategory._id) .expect(200) .expect('Content-Type', /json/) .end(function(err, res) { if (err) { return done(err); } category = res.body; done(); }); }); afterEach(function() { category = {}; }); it('should respond with the requested category', function() { category.name.should.equal('New Category'); category.info.should.equal('This is the brand new category!!!'); }); }); describe('PUT /api/categories/:id', function() { var updatedCategory beforeEach(function(done) { request(app) .put('/api/categories/' + newCategory._id) .send({ name: 'Updated Category', info: 'This is the updated category!!!' }) .expect(200) .expect('Content-Type', /json/) .end(function(err, res) { if (err) { return done(err); } updatedCategory = res.body; done(); }); }); afterEach(function() { updatedCategory = {}; }); it('should respond with the updated category', function() { updatedCategory.name.should.equal('Updated Category'); updatedCategory.info.should.equal('This is the updated category!!!'); }); }); describe('DELETE /api/categories/:id', function() { it('should respond with 204 on successful removal', function(done) { request(app) .delete('/api/categories/' + newCategory._id) .expect(204) .end(function(err, res) { if (err) { return done(err); } done(); }); }); it('should respond with 404 when category does not exist', function(done) { request(app) .delete('/api/categories/' + newCategory._id) .expect(404) .end(function(err, res) { if (err) { return done(err); } done(); }); }); }); }); |
Commits for YouAndWeb_TwoToc.fr-KzWVa7/twotoc/server/api/category/category.integration.js
Revision | Author | Commited | Message |
---|---|---|---|
a98e8d ... | FSinnona | Thu 26 Nov, 2015 13:26:45 +0000 | Creazione organizza |