Skip to content

Commit

Permalink
Merge 96637e7 into 2695a5f
Browse files Browse the repository at this point in the history
  • Loading branch information
salilagrawal committed Jul 18, 2019
2 parents 2695a5f + 96637e7 commit 5ce3f6d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/utils.js
Expand Up @@ -63,7 +63,7 @@ export function hasError(resource) {
* @private
*/
export function parseReqDesc(reqDesc) {
reqDesc.method = (reqDesc.method || 'get').toLowerCase();
reqDesc.method = (reqDesc.method || 'GET').toUpperCase();

if (reqDesc.hasOwnProperty('withCredentials')) {
// eslint-disable-next-line no-console
Expand Down
23 changes: 15 additions & 8 deletions tests/utils.spec.js
Expand Up @@ -133,18 +133,18 @@ describe('Utils', () => {
expect(results).toBeInstanceOf(Object);
});

it('normalizes method name lowercase', () => {
it('normalizes method name uppercase', () => {
results = parseReqDesc({
method: 'Post'
});

expect(results).toHaveProperty('method', 'post');
expect(results).toHaveProperty('method', 'POST');
});

it('normalizes method as get if missing', () => {
it('normalizes method as GET if missing', () => {
results = parseReqDesc({});

expect(results).toHaveProperty('method', 'get');
expect(results).toHaveProperty('method', 'GET');
});

it('issues deprecation warning if withCredentials sets', () => {
Expand Down Expand Up @@ -196,18 +196,25 @@ describe('Utils', () => {
it('passes entries through parseReqDesc', () => {
jest.spyOn(utils, 'parseReqDesc');
results = parseApiDesc({
test: {},
test1: {},
test2: {
method: 'Post'
},
test3: {
method: 'patch'
}
});

expect(results).toHaveProperty('test', expect.objectContaining({
method: 'get'
expect(results).toHaveProperty('test1', expect.objectContaining({
method: 'GET'
}));

expect(results).toHaveProperty('test2', expect.objectContaining({
method: 'post'
method: 'POST'
}));

expect(results).toHaveProperty('test3', expect.objectContaining({
method: 'PATCH'
}));
});
});
Expand Down

0 comments on commit 5ce3f6d

Please sign in to comment.