Skip to content

Commit 703c396

Browse files
committed
Revert the change so job execute a single time
1 parent cf83992 commit 703c396

File tree

1 file changed

+28
-30
lines changed

1 file changed

+28
-30
lines changed

spec/CloudCode.spec.js

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,38 +1547,36 @@ describe('Cloud Code', () => {
15471547
});
15481548

15491549
describe('cloud jobs', () => {
1550-
for (let x = 0; x < 1000; x++) {
1551-
fit('should define a job', done => {
1552-
expect(() => {
1553-
Parse.Cloud.job('myJob', ({ message }) => {
1554-
message('Hello, world!!!');
1555-
});
1556-
}).not.toThrow();
1550+
it('should define a job', done => {
1551+
expect(() => {
1552+
Parse.Cloud.job('myJob', ({ message }) => {
1553+
message('Hello, world!!!');
1554+
});
1555+
}).not.toThrow();
15571556

1558-
request({
1559-
method: 'POST',
1560-
url: 'http://localhost:8378/1/jobs/myJob',
1561-
headers: {
1562-
'X-Parse-Application-Id': Parse.applicationId,
1563-
'X-Parse-Master-Key': Parse.masterKey,
1564-
},
1557+
request({
1558+
method: 'POST',
1559+
url: 'http://localhost:8378/1/jobs/myJob',
1560+
headers: {
1561+
'X-Parse-Application-Id': Parse.applicationId,
1562+
'X-Parse-Master-Key': Parse.masterKey,
1563+
},
1564+
})
1565+
.then(async response => {
1566+
const jobStatusId = response.headers['x-parse-job-status-id'];
1567+
const checkJobStatus = async () => {
1568+
const jobStatus = await new Parse.Query('_JobStatus').get(jobStatusId, {
1569+
useMasterKey: true,
1570+
});
1571+
return jobStatus.get('finishedAt') && jobStatus.get('message') === 'Hello, world!!!';
1572+
};
1573+
while (!(await checkJobStatus())) {
1574+
await new Promise(resolve => setTimeout(resolve, 100));
1575+
}
15651576
})
1566-
.then(async response => {
1567-
const jobStatusId = response.headers['x-parse-job-status-id'];
1568-
const checkJobStatus = async () => {
1569-
const jobStatus = await new Parse.Query('_JobStatus').get(jobStatusId, {
1570-
useMasterKey: true,
1571-
});
1572-
return jobStatus.get('finishedAt') && jobStatus.get('message') === 'Hello, world!!!';
1573-
};
1574-
while (!(await checkJobStatus())) {
1575-
await new Promise(resolve => setTimeout(resolve, 100));
1576-
}
1577-
})
1578-
.then(done)
1579-
.catch(done.fail);
1580-
});
1581-
}
1577+
.then(done)
1578+
.catch(done.fail);
1579+
});
15821580

15831581
it('should not run without master key', done => {
15841582
expect(() => {

0 commit comments

Comments
 (0)