Skip to content

Commit 36cea18

Browse files
committed
Failing Cloud.run test for parse-community#1347
1 parent a5e7dfb commit 36cea18

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

src/__tests__/Cloud-test.js

+49
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,22 @@ jest.dontMock('../ParseError');
1515
jest.dontMock('../ParseObject');
1616
jest.dontMock('../ParseQuery');
1717
jest.dontMock('../Push');
18+
jest.dontMock('../parseDate');
19+
jest.dontMock('../ObjectStateMutations');
20+
jest.dontMock('../SingleInstanceStateController');
21+
jest.dontMock('../UniqueInstanceStateController');
1822

1923
const Cloud = require('../Cloud');
2024
const CoreManager = require('../CoreManager');
2125
const Push = require('../Push');
26+
const ParseObject = require('../ParseObject').default;
2227

2328
const defaultController = CoreManager.getCloudController();
2429

2530
describe('Cloud', () => {
2631
beforeEach(() => {
32+
ParseObject.enableSingleInstance();
33+
2734
const run = jest.fn();
2835
const getJobsData = jest.fn();
2936
const startJob = jest.fn();
@@ -216,6 +223,48 @@ describe('CloudController', () => {
216223
});
217224
});
218225

226+
it('run same function twice with different responses', async () => {
227+
const request = jest.fn();
228+
request.mockReturnValue(
229+
Promise.resolve({
230+
success: true,
231+
result: {
232+
objectId: 'abc123',
233+
className: 'Item',
234+
__type: 'Object',
235+
createdAt: '2015-01-01T00:00:00.000Z',
236+
updatedAt: '2015-01-01T00:00:00.000Z',
237+
label: 'foobar',
238+
},
239+
})
240+
);
241+
242+
const ajax = jest.fn();
243+
CoreManager.setRESTController({ request: request, ajax: ajax });
244+
245+
const response1 = await Cloud.run('myfunction');
246+
expect(response1.get('label')).toBe('foobar');
247+
248+
request.mockReturnValue(
249+
Promise.resolve({
250+
success: true,
251+
result: {
252+
objectId: 'abc123',
253+
className: 'Item',
254+
__type: 'Object',
255+
createdAt: '2015-01-01T00:00:00.000Z',
256+
updatedAt: '2015-01-01T00:00:00.000Z',
257+
label2: 'control to confirm correct mock usage',
258+
// Note that 'label' is not returned
259+
},
260+
})
261+
);
262+
263+
const response2 = await Cloud.run('myfunction');
264+
expect(response2.get('label2')).toBe('control to confirm correct mock usage');
265+
expect(response2.get('label')).toBe(undefined); // Failing test PR #1442
266+
});
267+
219268
it('startJob passes encoded requests', () => {
220269
Cloud.startJob('myJob', {
221270
value: 12,

src/__tests__/ParseUser-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ describe('ParseUser', () => {
992992
expect(user2.isCurrent()).toBe(true);
993993
expect(user2.id).toBe('uid2');
994994
expect(user2.get('username')).toBe('username');
995-
expect(user2.get('fieldToBeDeleted')).toBe(undefined); // Failing test
995+
expect(user2.get('fieldToBeDeleted')).toBe(undefined); // Failing test PR #1442
996996
});
997997

998998
it('can retreive a user with sessionToken (me)', async () => {

0 commit comments

Comments
 (0)