Skip to content

Commit aa9ff58

Browse files
authored
Merge branch 'alpha' into dependabot/npm_and_yarn/babel/helper-wrap-function-7.20.5
2 parents a8904df + 8863f91 commit aa9ff58

File tree

4 files changed

+72
-66
lines changed

4 files changed

+72
-66
lines changed

integration/test/ParseCloudTest.js

+19-24
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ const assert = require('assert');
44
const Parse = require('../../node');
55
const sleep = require('./sleep');
66

7+
const waitForJobStatus = async (jobStatusId, status) => {
8+
const checkJobStatus = async () => {
9+
const result = await Parse.Cloud.getJobStatus(jobStatusId);
10+
return result && result.get('status') === status;
11+
};
12+
while (!(await checkJobStatus())) {
13+
await sleep(100);
14+
}
15+
};
16+
717
describe('Parse Cloud', () => {
818
it('run function', done => {
919
const params = { key1: 'value2', key2: 'value1' };
@@ -86,14 +96,8 @@ describe('Parse Cloud', () => {
8696
it('run job', async () => {
8797
const params = { startedBy: 'Monty Python' };
8898
const jobStatusId = await Parse.Cloud.startJob('CloudJob1', params);
99+
await waitForJobStatus(jobStatusId, 'succeeded');
89100

90-
const checkJobStatus = async () => {
91-
const result = await Parse.Cloud.getJobStatus(jobStatusId);
92-
return result && result.get('status') === 'succeeded';
93-
};
94-
while (!(await checkJobStatus())) {
95-
await sleep(100);
96-
}
97101
const jobStatus = await Parse.Cloud.getJobStatus(jobStatusId);
98102
assert.equal(jobStatus.get('status'), 'succeeded');
99103
assert.equal(jobStatus.get('params').startedBy, 'Monty Python');
@@ -104,14 +108,8 @@ describe('Parse Cloud', () => {
104108

105109
let jobStatus = await Parse.Cloud.getJobStatus(jobStatusId);
106110
assert.equal(jobStatus.get('status'), 'running');
111+
await waitForJobStatus(jobStatusId, 'succeeded');
107112

108-
const checkJobStatus = async () => {
109-
const result = await Parse.Cloud.getJobStatus(jobStatusId);
110-
return result && result.get('status') === 'succeeded';
111-
};
112-
while (!(await checkJobStatus())) {
113-
await sleep(100);
114-
}
115113
jobStatus = await Parse.Cloud.getJobStatus(jobStatusId);
116114
assert.equal(jobStatus.get('status'), 'succeeded');
117115
});
@@ -126,16 +124,13 @@ describe('Parse Cloud', () => {
126124
});
127125
});
128126

129-
it('run failing job', done => {
130-
Parse.Cloud.startJob('CloudJobFailing')
131-
.then(jobStatusId => {
132-
return Parse.Cloud.getJobStatus(jobStatusId);
133-
})
134-
.then(jobStatus => {
135-
assert.equal(jobStatus.get('status'), 'failed');
136-
assert.equal(jobStatus.get('message'), 'cloud job failed');
137-
done();
138-
});
127+
it('run failing job', async () => {
128+
const jobStatusId = await Parse.Cloud.startJob('CloudJobFailing');
129+
await waitForJobStatus(jobStatusId, 'failed');
130+
131+
const jobStatus = await Parse.Cloud.getJobStatus(jobStatusId);
132+
assert.equal(jobStatus.get('status'), 'failed');
133+
assert.equal(jobStatus.get('message'), 'cloud job failed');
139134
});
140135

141136
it('get jobs data', done => {

integration/test/ParseDistTest.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
const puppeteer = require('puppeteer');
2+
let browser = null;
23
let page = null;
34
for (const fileName of ['parse.js', 'parse.min.js']) {
4-
beforeAll(async () => {
5-
const browser = await puppeteer.launch();
6-
page = await browser.newPage();
7-
await page.goto(`http://localhost:1337/${fileName}`);
8-
});
95
describe(`Parse Dist Test ${fileName}`, () => {
6+
beforeEach(async () => {
7+
browser = await puppeteer.launch();
8+
page = await browser.newPage();
9+
await page.goto(`http://localhost:1337/${fileName}`);
10+
});
11+
12+
afterEach(async () => {
13+
await page.close();
14+
await browser.close();
15+
});
16+
1017
it('can save an object', async () => {
1118
const response = await page.evaluate(async () => {
1219
const object = await new Parse.Object('TestObject').save();
@@ -17,6 +24,7 @@ for (const fileName of ['parse.js', 'parse.min.js']) {
1724
expect(obj).toBeDefined();
1825
expect(obj.id).toEqual(response);
1926
});
27+
2028
it('can query an object', async () => {
2129
const obj = await new Parse.Object('TestObject').save();
2230
const response = await page.evaluate(async () => {

integration/test/helper.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,14 @@ beforeAll(async () => {
166166

167167
afterEach(async () => {
168168
await Parse.User.logOut();
169+
// Connection close events are not immediate on node 10+... wait a bit
170+
await sleep(0);
171+
if (Object.keys(openConnections).length > 0) {
172+
console.warn('There were open connections to the server left after the test finished');
173+
}
169174
Parse.Storage._clear();
170175
await TestUtils.destroyAllDataPermanently(true);
171176
destroyAliveConnections();
172-
// Connection close events are not immediate on node 10+... wait a bit
173-
await sleep(0);
174177
if (didChangeConfiguration) {
175178
await reconfigureServer();
176179
}

package-lock.json

+35-35
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)