Improve test code (#7121)

This commit is contained in:
Diamond Lewis
2021-01-13 12:40:18 -05:00
committed by GitHub
parent e08618e377
commit c8cdcbe10e
4 changed files with 13 additions and 102 deletions

View File

@@ -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');
});
});