I'm a bit new to testing and am working on editing tests for a MEAN-stack web app generated by the yeoman angular-fullstack generator. I've POSTed a dummy object into my mongo database and can see the object and its ID
through the mongo shell.
I can perform GET
and PUT
requests on the object; however, trying to perform a PATCH request on the ID
returns OPERATION_PATH_UNRESOLVABLE
.
Does anyone have any suggestions as to why this may be happening?
I've included a sample of the code below, this code works perfectly for my other endpoints. I'm only receiving the error with one specific endpoint.
describe('PATCH /api/objects/:id', function() {
var patchedObject;
beforeEach(function(done) {
newObject.title = 'Patched Object';
newObject.section.Title = 'Patched Object Sec Title';
newObject.section.Body = 'Patched Object Sec Body';
newObject.section.Lists = ['Patched Sec List Item 0'];
newObject.images = ['N/A'];
newObject.date.startDate = '1/5/19';
newObject.date.endDate = '1/10/19';
newObject.duration = '5 Days';
newObject.location = 'VA';
newObject.isProgram = true;
newObject.hasRegistration = true;
newObject.linksOut.title = 'Patched Link';
newObject.linksOut.address = 'Patched Address';
newObject.backGround = 'black';
newObject.orderIndex = objects.length;
request(app)
.patch(`/api/promotions/${newObject._id}`)
.set('authorization', 'Bearer ' + token)
.send(newObject)
.expect(200)
.expect('Content-Type', /json/)
.end(function(err, res) {
if(err) {
return done(err);
}
patchedObject = res.body;
done();
});
});
afterEach(function() {
patchedObject = {};
});
it('should respond with the patched promotion when authenticated',
function() {
expect(patchedObject.title).to.equal('Patched Object');
});
});
I expect the output to be 200 but receive 500 Internal Server Error. My Logger returns OPERATION_PATH_UNRESOLVABLE