Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/ParseObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,9 @@ class ParseObject<T extends Attributes = Attributes> {

static _getRequestOptions(options: RequestOptions & FullOptions & { json?: boolean } = {}) {
const requestOptions: RequestOptions & FullOptions & { json?: boolean } = {};
if (Object.prototype.toString.call(options) !== '[object Object]') {
throw new Error('request options must be of type Object');
}
const { hasOwn } = Object;
if (hasOwn(options, 'useMasterKey')) {
requestOptions.useMasterKey = !!options.useMasterKey;
Expand Down
27 changes: 27 additions & 0 deletions src/__tests__/Cloud-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,4 +356,31 @@
});
expect(options.useMasterKey).toBe(false);
});

Check failure on line 359 in src/__tests__/Cloud-test.js

View workflow job for this annotation

GitHub Actions / Lint

Trailing spaces not allowed
it('run passes with empty options', () => {
const values = [undefined, {}];

const mockRun = jest.fn();
mockRun.mockReturnValue(Promise.resolve({ result: {} }));

CoreManager.setCloudController({
run: mockRun,
getJobsData: jest.fn(),
startJob: jest.fn(),
});

for (const value of values) {
mockRun.mockClear();
expect(() => Cloud.run('myfunction', {}, value)).not.toThrow();
expect(mockRun).toHaveBeenLastCalledWith('myfunction', {}, {});
}
});

it('run throws with invalid options', () => {
const values = [null, []];
for (const value of values) {
expect(() => Cloud.run('myfunction', {}, value)).toThrow();
}
});

Check failure on line 385 in src/__tests__/Cloud-test.js

View workflow job for this annotation

GitHub Actions / Lint

Trailing spaces not allowed
});
Loading