Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('can handle cloud code afterSave request', function() {
const publisher = new ParseCloudCodePublisher({});
publisher._onCloudCodeMessage = jasmine.createSpy('onCloudCodeMessage');
const request = {};
publisher.onCloudCodeAfterSave(request);
expect(publisher._onCloudCodeMessage).toHaveBeenCalledWith(
Parse.applicationId + 'afterSave',
request
);
});
it('should find in primary by default', done => {
const databaseAdapter = Config.get(Parse.applicationId).database.adapter;
const obj0 = new Parse.Object('MyObject');
obj0.set('boolKey', false);
const obj1 = new Parse.Object('MyObject');
obj1.set('boolKey', true);
Parse.Object.saveAll([obj0, obj1])
.then(() => {
spyOn(
databaseAdapter.database.serverConfig,
'cursor'
).and.callThrough();
const query = new Parse.Query('MyObject');
query.equalTo('boolKey', false);
return new Promise((resolve, reject) => {
op(
{
url: Parse.serverURL + '/schemas/' + className,
headers: {
'X-Parse-Application-Id': Parse.applicationId,
'X-Parse-Master-Key': Parse.masterKey,
},
json: true,
body: {
classLevelPermissions: permissions,
},
},
(error, response, body) => {
if (error) {
return reject(error);
}
if (body.error) {
return reject(body);
}
return resolve(body);
}
export function runLiveQueryEventHandlers(
data,
applicationId = Parse.applicationId
) {
if (
!_triggerStore ||
!_triggerStore[applicationId] ||
!_triggerStore[applicationId].LiveQuery
) {
return;
}
_triggerStore[applicationId].LiveQuery.forEach(handler => handler(data));
}
Parse.Object.saveAll(objectList).then((results) => {
equal(objectList.length, results.length);
return require('request-promise').get({
url: Parse.serverURL + "/classes/Object",
json: {
where: {
strings: {
$all: [ {$regex: '\^\\Qlazy\\E'} ]
}
}
},
headers: {
'X-Parse-Application-Id': Parse.applicationId,
'X-Parse-Javascript-Key': Parse.javaScriptKey
}
});
})
.then(function (results) {
static defaultPushChannel() {
return `${Parse.applicationId}-${PUSH_CHANNEL}`;
}
_onAfterSave(message: any): void {
logger.verbose(Parse.applicationId + 'afterSave is triggered');
let originalParseObject = null;
if (message.originalParseObject) {
originalParseObject = message.originalParseObject.toJSON();
}
const classLevelPermissions = message.classLevelPermissions;
const currentParseObject = message.currentParseObject.toJSON();
const className = currentParseObject.className;
logger.verbose(
'ClassName: %s | ObjectId: %s',
className,
currentParseObject.id
);
logger.verbose('Current client number : %d', this.clients.size);
const classSubscriptions = this.subscriptions.get(className);
return require('request-promise').get({
url: Parse.serverURL + "/classes/Object",
json: {
where: {
strings: {
$all: [
{$regex: '\^\\Qthe\\E'},
{$regex: '\^\\Qfox\\E'},
{$regex: '\^\\Qlazy\\E'}
]
}
}
},
headers: {
'X-Parse-Application-Id': Parse.applicationId,
'X-Parse-Javascript-Key': Parse.javaScriptKey
}
})
.then(function (results) {
equal(results.results.length, 1);
arrayContains(results.results, object);
return require('request-promise').get({
url: Parse.serverURL + "/classes/Object",
json: {
where: {
strings: {
$all: [
{$regex: '\^\\Qthe\\E'},
{$regex: '\^\\Qlazy\\E'}
]
onCloudCodeAfterSave(request: any): void {
this._onCloudCodeMessage(Parse.applicationId + 'afterSave', request);
}
beforeEach(async () => {
Config.get(Parse.applicationId).database.schemaCache.clear();
user1 = await Parse.User.signUp('user1', 'password');
user2 = await Parse.User.signUp('user2', 'password');
await Parse.User.logOut();
});