@@ -58,7 +58,7 @@ describe('<%= classedName %> API:', function() {
5858
5959 beforeEach ( function ( done ) {
6060 request ( app )
61- . get ( ' <%= route %>/' + new < %= classedName % > ._id)
61+ . get ( ` <%= route %>/${ new < %= classedName % > ._id} ` )
6262 .expect(200)
6363 .expect('Content-Type', /json/)
6464 .end((err, res) => {
@@ -85,7 +85,7 @@ describe('<%= classedName %> API:', function() {
8585
8686 beforeEach(function(done) {
8787 request(app)
88- . put ( ' <%= route %>/' + new < %= classedName % > ._id)
88+ .put(` < %= route % > / $ { new<% = c l a s s e d N a m e % > ._ i d } ` )
8989 . send ( {
9090 name : 'Updated <%= classedName %>' ,
9191 info : 'This is the updated <%= cameledName %>!!!'
@@ -105,16 +105,65 @@ describe('<%= classedName %> API:', function() {
105105 updated<%= classedName %> = {};
106106 });
107107
108- it('should respond with the updated < %= cameledName % > ', function() {
109- < %= expect ( ) % > updated < %= classedName % > . name < %= to ( ) % > . equal ( 'Updated <%= classedName %>' ) ;
110- < %= expect ( ) % > updated < %= classedName % > . info < %= to ( ) % > . equal ( 'This is the updated <%= cameledName %>!!!' ) ;
108+ it('should respond with the original <%= cameledName %>', function() {
109+ <%= expect() %>updated<%= classedName %>.name<%= to() %>.equal('New <%= classedName %>');
110+ <%= expect() %>updated<%= classedName %>.info<%= to() %>.equal('This is the brand new <%= cameledName %>!!!');
111+ });
112+
113+ it('should respond with the updated <%= cameledName %> on a subsequent GET', function(done) {
114+ request(app)
115+ .get(` < %= route % > / $ { new<% = c l a s s e d N a m e % > ._ i d } ` )
116+ . expect ( 200 )
117+ . expect ( 'Content-Type' , / j s o n / )
118+ . end ( ( err , res ) => {
119+ if ( err ) {
120+ return done ( err ) ;
121+ }
122+ let < %= cameledName % > = res . body ;
123+
124+ < %= expect ( ) % > < %= cameledName % > .name< %= to ( ) % > . equal ( 'Updated <%= classedName %>' ) ;
125+ < %= expect ( ) % > < %= cameledName % > .info< %= to ( ) % > . equal ( 'This is the updated <%= cameledName %>!!!' ) ;
126+
127+ done ( ) ;
128+ } ) ;
129+ } ) ;
130+ } ) ;
131+
132+ describe ( 'PATCH <%= route %>/:id' , function ( ) {
133+ var patched < %= classedName % > ;
134+
135+ beforeEach ( function ( done ) {
136+ request ( app )
137+ . patch ( `<%= route %>/${ new < %= classedName % > ._id} `)
138+ .send([
139+ { op: 'replace', path: '/name', value: 'Patched <%= classedName %>' },
140+ { op: 'replace', path: '/info', value: 'This is the patched <%= cameledName %>!!!' }
141+ ])
142+ .expect(200)
143+ .expect('Content-Type', /json/)
144+ .end(function(err, res) {
145+ if(err) {
146+ return done(err);
147+ }
148+ patched<%= classedName %> = res.body;
149+ done();
150+ });
151+ });
152+
153+ afterEach(function() {
154+ patched<%= classedName %> = {};
155+ });
156+
157+ it('should respond with the patched <%= cameledName %>', function() {
158+ <%= expect() %>patched<%= classedName %>.name<%= to() %>.equal('Patched <%= classedName %>');
159+ <%= expect() %>patched<%= classedName %>.info<%= to() %>.equal('This is the patched <%= cameledName %>!!!');
111160 });
112161 });
113162
114163 describe('DELETE <%= route %>/:id', function() {
115164 it('should respond with 204 on successful removal', function(done) {
116165 request(app)
117- . delete ( ' <%= route %>/' + new < %= classedName % > ._id)
166+ .delete(` < %= route % > / $ { new<% = c l a s s e d N a m e % > ._ i d } ` )
118167 . expect ( 204 )
119168 . end ( err => {
120169 if ( err ) {
@@ -126,7 +175,7 @@ describe('<%= classedName %> API:', function() {
126175
127176 it('should respond with 404 when <%= cameledName %> does not exist', function(done) {
128177 request(app)
129- . delete ( ' <%= route %>/' + new < %= classedName % > ._id)
178+ .delete(` < %= route % > / $ { new<% = c l a s s e d N a m e % > ._ i d } ` )
130179 . expect ( 404 )
131180 . end ( err => {
132181 if ( err ) {
0 commit comments