Skip to content

Commit

Permalink
Improve test code (#7121)
Browse files Browse the repository at this point in the history
  • Loading branch information
dplewis authored Jan 13, 2021
1 parent e08618e commit c8cdcbe
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 102 deletions.
8 changes: 4 additions & 4 deletions spec/Auth.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ describe('Auth', () => {
const acl = new Parse.ACL();
const role = new Parse.Role('roleloadtest' + i, acl);
role.getUsers().add([user]);
roles.push(role.save());
roles.push(role);
}
const savedRoles = await Promise.all(roles);
const savedRoles = await Parse.Object.saveAll(roles);
expect(savedRoles.length).toBe(rolesNumber);
const cloudRoles = await userAuth.getRolesForUser();
expect(cloudRoles.length).toBe(rolesNumber);
Expand All @@ -192,9 +192,9 @@ describe('Auth', () => {
const acl = new Parse.ACL();
const role = new Parse.Role('roleloadtest' + i, acl);
role.getUsers().add([user]);
roles.push(role.save());
roles.push(role);
}
const savedRoles = await Promise.all(roles);
const savedRoles = await Parse.Object.saveAll(roles);
expect(savedRoles.length).toBe(rolesNumber);
const cloudRoles = await userAuth.getRolesForUser();
expect(cloudRoles.length).toBe(rolesNumber);
Expand Down
33 changes: 8 additions & 25 deletions spec/ParseAPI.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,14 @@ const headers = {
};

describe_only_db('mongo')('miscellaneous', () => {
it('test rest_create_app', function (done) {
let appId;
Parse._request('POST', 'rest_create_app')
.then(res => {
expect(typeof res.application_id).toEqual('string');
expect(res.master_key).toEqual('master');
appId = res.application_id;
Parse.initialize(appId, 'unused');
const obj = new Parse.Object('TestObject');
obj.set('foo', 'bar');
return obj.save();
})
.then(() => {
const config = Config.get(appId);
return config.database.adapter.find('TestObject', { fields: {} }, {}, {});
})
.then(results => {
expect(results.length).toEqual(1);
expect(results[0]['foo']).toEqual('bar');
done();
})
.catch(error => {
fail(JSON.stringify(error));
done();
});
it('db contains document after successful save', async () => {
const obj = new Parse.Object('TestObject');
obj.set('foo', 'bar');
await obj.save();
const config = Config.get(defaultConfiguration.appId);
const results = await config.database.adapter.find('TestObject', { fields: {} }, {}, {});
expect(results.length).toEqual(1);
expect(results[0]['foo']).toEqual('bar');
});
});

Expand Down
2 changes: 1 addition & 1 deletion spec/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ const reconfigureServer = changedConfiguration => {
if (error) {
reject(error);
} else {
Parse.CoreManager.set('REQUEST_ATTEMPT_LIMIT', 1);
resolve(parseServer);
}
},
Expand All @@ -142,7 +143,6 @@ const reconfigureServer = changedConfiguration => {
});
cache.clear();
parseServer = ParseServer.start(newConfiguration);
parseServer.app.use(require('./testing-routes').router);
parseServer.expressApp.use('/1', err => {
console.error(err);
fail('should not call next');
Expand Down
72 changes: 0 additions & 72 deletions spec/testing-routes.js

This file was deleted.

0 comments on commit c8cdcbe

Please sign in to comment.