Skip to content

Commit e8a6b46

Browse files
committed
Improve test code (#7121)
1 parent b41704d commit e8a6b46

File tree

4 files changed

+13
-102
lines changed

4 files changed

+13
-102
lines changed

spec/Auth.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ describe('Auth', () => {
168168
const acl = new Parse.ACL();
169169
const role = new Parse.Role('roleloadtest' + i, acl);
170170
role.getUsers().add([user]);
171-
roles.push(role.save());
171+
roles.push(role);
172172
}
173-
const savedRoles = await Promise.all(roles);
173+
const savedRoles = await Parse.Object.saveAll(roles);
174174
expect(savedRoles.length).toBe(rolesNumber);
175175
const cloudRoles = await userAuth.getRolesForUser();
176176
expect(cloudRoles.length).toBe(rolesNumber);
@@ -192,9 +192,9 @@ describe('Auth', () => {
192192
const acl = new Parse.ACL();
193193
const role = new Parse.Role('roleloadtest' + i, acl);
194194
role.getUsers().add([user]);
195-
roles.push(role.save());
195+
roles.push(role);
196196
}
197-
const savedRoles = await Promise.all(roles);
197+
const savedRoles = await Parse.Object.saveAll(roles);
198198
expect(savedRoles.length).toBe(rolesNumber);
199199
const cloudRoles = await userAuth.getRolesForUser();
200200
expect(cloudRoles.length).toBe(rolesNumber);

spec/ParseAPI.spec.js

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,14 @@ const headers = {
2424
};
2525

2626
describe_only_db('mongo')('miscellaneous', () => {
27-
it('test rest_create_app', function (done) {
28-
let appId;
29-
Parse._request('POST', 'rest_create_app')
30-
.then(res => {
31-
expect(typeof res.application_id).toEqual('string');
32-
expect(res.master_key).toEqual('master');
33-
appId = res.application_id;
34-
Parse.initialize(appId, 'unused');
35-
const obj = new Parse.Object('TestObject');
36-
obj.set('foo', 'bar');
37-
return obj.save();
38-
})
39-
.then(() => {
40-
const config = Config.get(appId);
41-
return config.database.adapter.find('TestObject', { fields: {} }, {}, {});
42-
})
43-
.then(results => {
44-
expect(results.length).toEqual(1);
45-
expect(results[0]['foo']).toEqual('bar');
46-
done();
47-
})
48-
.catch(error => {
49-
fail(JSON.stringify(error));
50-
done();
51-
});
27+
it('db contains document after successful save', async () => {
28+
const obj = new Parse.Object('TestObject');
29+
obj.set('foo', 'bar');
30+
await obj.save();
31+
const config = Config.get(defaultConfiguration.appId);
32+
const results = await config.database.adapter.find('TestObject', { fields: {} }, {}, {});
33+
expect(results.length).toEqual(1);
34+
expect(results[0]['foo']).toEqual('bar');
5235
});
5336
});
5437

spec/helper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ const reconfigureServer = changedConfiguration => {
135135
if (error) {
136136
reject(error);
137137
} else {
138+
Parse.CoreManager.set('REQUEST_ATTEMPT_LIMIT', 1);
138139
resolve(parseServer);
139140
}
140141
},
@@ -143,7 +144,6 @@ const reconfigureServer = changedConfiguration => {
143144
});
144145
cache.clear();
145146
parseServer = ParseServer.start(newConfiguration);
146-
parseServer.app.use(require('./testing-routes').router);
147147
parseServer.expressApp.use('/1', err => {
148148
console.error(err);
149149
fail('should not call next');

spec/testing-routes.js

Lines changed: 0 additions & 72 deletions
This file was deleted.

0 commit comments

Comments
 (0)