Skip to content

Commit 0eb66d7

Browse files
author
Marcus Olsson
committed
fix: Add fix for when passing null as Parse.Cloud.run option (#2622)
1 parent 24fa80d commit 0eb66d7

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/ParseObject.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,9 @@ class ParseObject<T extends Attributes = Attributes> {
514514

515515
static _getRequestOptions(options: RequestOptions & FullOptions & { json?: boolean } = {}) {
516516
const requestOptions: RequestOptions & FullOptions & { json?: boolean } = {};
517+
if (!options) {
518+
return requestOptions;
519+
}
517520
const { hasOwn } = Object;
518521
if (hasOwn(options, 'useMasterKey')) {
519522
requestOptions.useMasterKey = !!options.useMasterKey;

src/__tests__/ParseObject-test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3543,3 +3543,23 @@ describe('ParseObject pin', () => {
35433543
CoreManager.set('NODE_LOGGING', false);
35443544
});
35453545
});
3546+
3547+
describe('ParseObject._getRequestOptions', () => {
3548+
it('returns empty object when options is null', () => {
3549+
const requestOptions = ParseObject._getRequestOptions(null);
3550+
3551+
expect(requestOptions).toEqual({});
3552+
});
3553+
3554+
it('returns empty object when options is an empty string', () => {
3555+
const requestOptions = ParseObject._getRequestOptions("");
3556+
3557+
expect(requestOptions).toEqual({});
3558+
});
3559+
3560+
it('returns empty object when options is undefined', () => {
3561+
const requestOptions = ParseObject._getRequestOptions(undefined);
3562+
3563+
expect(requestOptions).toEqual({});
3564+
});
3565+
});

0 commit comments

Comments
 (0)