* Start DB runner from tests * Connect GridstoreAdapter only when needed * removes unused package * better test errors reporting * Adds support for __op.Delete * Better test error reporting * Makes sure all tests can run without crashing * Use xdescribe to skip test suite * Removes unused dependencies * Let volatiles classes be created with PG on start * Do not fail if class dont exist * adds index.spec.js to the pg suite * Use a new config each test to prevent side effects * Enable EmailVerificationToken specs with pg * Makes sure failure output is not cut * Reduces number of ignored tests in ParseObject.spec * Inspect reconfiguration errors * Mark GlobalConfig is incompatible with PG - Problem is with nested updates (param.prop = value) * PG: Nested JSON queries and updates - Adds support for nested json and . operator queries - Adds debug support for PG adapter - Adds loglevel support in helper * Enable working specs in ParseUser * Sets default logLevel in tests to undefined * Adds File type support, retores purchaseValidation specs * Adds support for updating jsonb objects - Restores PushController tests * Proper implementation of deleteByQuery and ORs - Adds ParseInstallation spec to the test suite * xit only failing tests * Nit on ParseAPI spec * add sorting operator * properly bound order keys * reverts describe_only_db behavior * Enables passing tests * Adds basic support for relations, upsertOneObject aliased to createObject * progress on queries options * Fix ACL update related problems * Creates relation tables on class creation * Adds Relation tests * remove flaky tests * use promises instead of CB * disable flaky test * nits * Fixes on schema spec - Next thing is to implemenet geopoint and files correctly * fix failues * Basic GeoPoint support * Adds support for $nearSphere/$maxDistance geopoint queries * enable passing tests * drop tables afterEach for PG, clean up relation tables too * Better initialization/dropTables
195 lines
5.4 KiB
JavaScript
195 lines
5.4 KiB
JavaScript
var auth = require('../src/Auth');
|
|
var Config = require('../src/Config');
|
|
var rest = require('../src/rest');
|
|
var InstallationsRouter = require('../src/Routers/InstallationsRouter').InstallationsRouter;
|
|
|
|
describe('InstallationsRouter', () => {
|
|
it('uses find condition from request.body', (done) => {
|
|
var config = new Config('test');
|
|
var androidDeviceRequest = {
|
|
'installationId': '12345678-abcd-abcd-abcd-123456789abc',
|
|
'deviceType': 'android'
|
|
};
|
|
var iosDeviceRequest = {
|
|
'installationId': '12345678-abcd-abcd-abcd-123456789abd',
|
|
'deviceType': 'ios'
|
|
};
|
|
var request = {
|
|
config: config,
|
|
auth: auth.master(config),
|
|
body: {
|
|
where: {
|
|
deviceType: 'android'
|
|
}
|
|
},
|
|
query: {},
|
|
info: {}
|
|
};
|
|
|
|
var router = new InstallationsRouter();
|
|
rest.create(config, auth.nobody(config), '_Installation', androidDeviceRequest)
|
|
.then(() => {
|
|
return rest.create(config, auth.nobody(config), '_Installation', iosDeviceRequest);
|
|
}).then(() => {
|
|
return router.handleFind(request);
|
|
}).then((res) => {
|
|
var results = res.response.results;
|
|
expect(results.length).toEqual(1);
|
|
done();
|
|
}).catch((err) => {
|
|
fail(JSON.stringify(err));
|
|
done();
|
|
});
|
|
});
|
|
|
|
it('uses find condition from request.query', (done) => {
|
|
var config = new Config('test');
|
|
var androidDeviceRequest = {
|
|
'installationId': '12345678-abcd-abcd-abcd-123456789abc',
|
|
'deviceType': 'android'
|
|
};
|
|
var iosDeviceRequest = {
|
|
'installationId': '12345678-abcd-abcd-abcd-123456789abd',
|
|
'deviceType': 'ios'
|
|
};
|
|
var request = {
|
|
config: config,
|
|
auth: auth.master(config),
|
|
body: {},
|
|
query: {
|
|
where: {
|
|
deviceType: 'android'
|
|
}
|
|
},
|
|
info: {}
|
|
};
|
|
|
|
var router = new InstallationsRouter();
|
|
rest.create(config, auth.nobody(config), '_Installation', androidDeviceRequest)
|
|
.then(() => {
|
|
return rest.create(config, auth.nobody(config), '_Installation', iosDeviceRequest);
|
|
}).then(() => {
|
|
return router.handleFind(request);
|
|
}).then((res) => {
|
|
var results = res.response.results;
|
|
expect(results.length).toEqual(1);
|
|
done();
|
|
}).catch((err) => {
|
|
console.error(err);
|
|
fail(JSON.stringify(err));
|
|
done();
|
|
});
|
|
});
|
|
|
|
it('query installations with limit = 0', (done) => {
|
|
var config = new Config('test');
|
|
var androidDeviceRequest = {
|
|
'installationId': '12345678-abcd-abcd-abcd-123456789abc',
|
|
'deviceType': 'android'
|
|
};
|
|
var iosDeviceRequest = {
|
|
'installationId': '12345678-abcd-abcd-abcd-123456789abd',
|
|
'deviceType': 'ios'
|
|
};
|
|
var request = {
|
|
config: config,
|
|
auth: auth.master(config),
|
|
body: {},
|
|
query: {
|
|
limit: 0
|
|
},
|
|
info: {}
|
|
};
|
|
|
|
var config = new Config('test');
|
|
var router = new InstallationsRouter();
|
|
rest.create(config, auth.nobody(config), '_Installation', androidDeviceRequest)
|
|
.then(() => {
|
|
return rest.create(config, auth.nobody(config), '_Installation', iosDeviceRequest);
|
|
}).then(() => {
|
|
return router.handleFind(request);
|
|
}).then((res) => {
|
|
var response = res.response;
|
|
expect(response.results.length).toEqual(0);
|
|
done();
|
|
}).catch((err) => {
|
|
fail(JSON.stringify(err));
|
|
done();
|
|
});
|
|
});
|
|
|
|
it('query installations with count = 1', done => {
|
|
var config = new Config('test');
|
|
var androidDeviceRequest = {
|
|
'installationId': '12345678-abcd-abcd-abcd-123456789abc',
|
|
'deviceType': 'android'
|
|
};
|
|
var iosDeviceRequest = {
|
|
'installationId': '12345678-abcd-abcd-abcd-123456789abd',
|
|
'deviceType': 'ios'
|
|
};
|
|
var request = {
|
|
config: config,
|
|
auth: auth.master(config),
|
|
body: {},
|
|
query: {
|
|
count: 1
|
|
},
|
|
info: {}
|
|
};
|
|
|
|
var router = new InstallationsRouter();
|
|
rest.create(config, auth.nobody(config), '_Installation', androidDeviceRequest)
|
|
.then(() => rest.create(config, auth.nobody(config), '_Installation', iosDeviceRequest))
|
|
.then(() => router.handleFind(request))
|
|
.then((res) => {
|
|
var response = res.response;
|
|
expect(response.results.length).toEqual(2);
|
|
expect(response.count).toEqual(2);
|
|
done();
|
|
})
|
|
.catch(error => {
|
|
fail(JSON.stringify(error));
|
|
done();
|
|
})
|
|
});
|
|
|
|
it('query installations with limit = 0 and count = 1', (done) => {
|
|
var config = new Config('test');
|
|
var androidDeviceRequest = {
|
|
'installationId': '12345678-abcd-abcd-abcd-123456789abc',
|
|
'deviceType': 'android'
|
|
};
|
|
var iosDeviceRequest = {
|
|
'installationId': '12345678-abcd-abcd-abcd-123456789abd',
|
|
'deviceType': 'ios'
|
|
};
|
|
var request = {
|
|
config: config,
|
|
auth: auth.master(config),
|
|
body: {},
|
|
query: {
|
|
limit: 0,
|
|
count: 1
|
|
},
|
|
info: {}
|
|
};
|
|
|
|
var router = new InstallationsRouter();
|
|
rest.create(config, auth.nobody(config), '_Installation', androidDeviceRequest)
|
|
.then(() => {
|
|
return rest.create(config, auth.nobody(config), '_Installation', iosDeviceRequest);
|
|
}).then(() => {
|
|
return router.handleFind(request);
|
|
}).then((res) => {
|
|
var response = res.response;
|
|
expect(response.results.length).toEqual(0);
|
|
expect(response.count).toEqual(2);
|
|
done();
|
|
}).catch((err) => {
|
|
fail(JSON.stringify(err));
|
|
done();
|
|
});
|
|
});
|
|
});
|