Skip to content

Commit

Permalink
feat(request): add patch method resolve EDITOR-1411
Browse files Browse the repository at this point in the history
  • Loading branch information
Valetudox committed Apr 21, 2018
1 parent 336dcb0 commit 45aa554
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ class SuiteRequest {
return this._request('GET', path);
}

patch(path, data) {
return this._request('PATCH', path, data);
}

post(path, data) {
return this._request('POST', path, data);
}
Expand Down
18 changes: 18 additions & 0 deletions lib/request.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ describe('SuiteRequest', function() {
expect(requestArgument.headers['x-ems-auth']).to.have.string('SignedHeaders=content-type;host;x-ems-date,');
});

it('should sign headers of PATCH request', function*() {
yield suiteRequest.patch('/path', { name: 'Almanach' });

const requestArgument = requestStub.args[0][0];
expect(requestArgument.headers['x-ems-auth']).to.have.string('SignedHeaders=content-type;host;x-ems-date,');
});

it('should sign headers of POST request', function*() {
yield suiteRequest.post('/path', { name: 'Almanach' });

Expand Down Expand Up @@ -110,6 +117,17 @@ describe('SuiteRequest', function() {
});
});

it('should sign the payload of PATCH request', function*() {
const payload = { name: 'Test' };
this.sandbox.spy(Escher.prototype, 'signRequest');

yield suiteRequest.patch('/path', payload);

expect(Escher.prototype.signRequest.callCount).to.eql(1);
const firstCall = Escher.prototype.signRequest.getCall(0);
expect(firstCall.args[1]).to.eql(JSON.stringify(payload));
});

it('should sign the payload of POST request', function*() {
const payload = { name: 'Test' };
this.sandbox.spy(Escher.prototype, 'signRequest');
Expand Down

0 comments on commit 45aa554

Please sign in to comment.