-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathbasename.integration.js
147 lines (122 loc) · 3.9 KB
/
basename.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('<%= relativeRequire('server') %>');
import request from 'supertest';<% if(filters.models) { %>
var new<%= classedName %>;<% } %>
describe('<%= classedName %> API:', function() {
describe('GET <%= route %>', function() {
var <%= cameledName %>s;
beforeEach(function(done) {
request(app)
.get('<%= route %>')
.expect(200)
.expect('Content-Type', /json/)
.end((err, res) => {
if (err) {
return done(err);
}
<%= cameledName %>s = res.body;
done();
});
});
it('should respond with JSON array', function() {
<%= expect() %><%= cameledName %>s<%= to() %>.be.instanceOf(Array);
});
});<% if(filters.models) { %>
describe('POST <%= route %>', function() {
beforeEach(function(done) {
request(app)
.post('<%= route %>')
.send({
name: 'New <%= classedName %>',
info: 'This is the brand new <%= cameledName %>!!!'
})
.expect(201)
.expect('Content-Type', /json/)
.end((err, res) => {
if (err) {
return done(err);
}
new<%= classedName %> = res.body;
done();
});
});
it('should respond with the newly created <%= cameledName %>', function() {
<%= expect() %>new<%= classedName %>.name<%= to() %>.equal('New <%= classedName %>');
<%= expect() %>new<%= classedName %>.info<%= to() %>.equal('This is the brand new <%= cameledName %>!!!');
});
});
describe('GET <%= route %>/:id', function() {
var <%= cameledName %>;
beforeEach(function(done) {
request(app)
.get('<%= route %>/' + new<%= classedName %>._id)
.expect(200)
.expect('Content-Type', /json/)
.end((err, res) => {
if (err) {
return done(err);
}
<%= cameledName %> = res.body;
done();
});
});
afterEach(function() {
<%= cameledName %> = {};
});
it('should respond with the requested <%= cameledName %>', function() {
<%= expect() %><%= cameledName %>.name<%= to() %>.equal('New <%= classedName %>');
<%= expect() %><%= cameledName %>.info<%= to() %>.equal('This is the brand new <%= cameledName %>!!!');
});
});
describe('PUT <%= route %>/:id', function() {
var updated<%= classedName %>;
beforeEach(function(done) {
request(app)
.put('<%= route %>/' + new<%= classedName %>._id)
.send({
name: 'Updated <%= classedName %>',
info: 'This is the updated <%= cameledName %>!!!'
})
.expect(200)
.expect('Content-Type', /json/)
.end(function(err, res) {
if (err) {
return done(err);
}
updated<%= classedName %> = res.body;
done();
});
});
afterEach(function() {
updated<%= classedName %> = {};
});
it('should respond with the updated <%= cameledName %>', function() {
<%= expect() %>updated<%= classedName %>.name<%= to() %>.equal('Updated <%= classedName %>');
<%= expect() %>updated<%= classedName %>.info<%= to() %>.equal('This is the updated <%= cameledName %>!!!');
});
});
describe('DELETE <%= route %>/:id', function() {
it('should respond with 204 on successful removal', function(done) {
request(app)
.delete('<%= route %>/' + new<%= classedName %>._id)
.expect(204)
.end((err, res) => {
if (err) {
return done(err);
}
done();
});
});
it('should respond with 404 when <%= cameledName %> does not exist', function(done) {
request(app)
.delete('<%= route %>/' + new<%= classedName %>._id)
.expect(404)
.end((err, res) => {
if (err) {
return done(err);
}
done();
});
});
});<% } %>
});