Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions spec/ParseLiveQuery.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('ParseLiveQuery', function () {
silent: true,
});
Parse.Cloud.afterLiveQueryEvent('TestObject', req => {
expect(req.event).toBe('Create');
expect(req.event).toBe('create');
expect(req.user).toBeUndefined();
expect(req.object.get('foo')).toBe('bar');
});
Expand Down Expand Up @@ -68,7 +68,7 @@ describe('ParseLiveQuery', function () {
await object.save();

Parse.Cloud.afterLiveQueryEvent('TestObject', req => {
expect(req.event).toBe('Update');
expect(req.event).toBe('update');
expect(req.user).toBeUndefined();
expect(req.object.get('foo')).toBe('bar');
expect(req.original.get('foo')).toBeUndefined();
Expand All @@ -92,7 +92,7 @@ describe('ParseLiveQuery', function () {
silent: true,
});
Parse.Cloud.afterLiveQueryEvent('TestObject', req => {
expect(req.event).toBe('Enter');
expect(req.event).toBe('enter');
expect(req.user).toBeUndefined();
expect(req.object.get('foo')).toBe('bar');
expect(req.original.get('foo')).toBeUndefined();
Expand Down Expand Up @@ -123,7 +123,7 @@ describe('ParseLiveQuery', function () {
silent: true,
});
Parse.Cloud.afterLiveQueryEvent('TestObject', req => {
expect(req.event).toBe('Leave');
expect(req.event).toBe('leave');
expect(req.user).toBeUndefined();
expect(req.object.get('foo')).toBeUndefined();
expect(req.original.get('foo')).toBe('bar');
Expand Down Expand Up @@ -155,7 +155,7 @@ describe('ParseLiveQuery', function () {
silent: true,
});
Parse.Cloud.afterLiveQueryEvent('TestObject', req => {
expect(req.event).toBe('Delete');
expect(req.event).toBe('delete');
expect(req.user).toBeUndefined();
req.object.set('foo', 'bar');
});
Expand Down Expand Up @@ -315,7 +315,7 @@ describe('ParseLiveQuery', function () {
silent: true,
});
Parse.Cloud.afterLiveQueryEvent('TestObject', req => {
expect(req.event).toBe('Create');
expect(req.event).toBe('create');
expect(req.user).toBeUndefined();
expect(req.object.get('foo')).toBe('bar');
});
Expand Down Expand Up @@ -345,7 +345,7 @@ describe('ParseLiveQuery', function () {
await object.save();

Parse.Cloud.afterLiveQueryEvent('TestObject', req => {
expect(req.event).toBe('Update');
expect(req.event).toBe('update');
expect(req.user).toBeUndefined();
expect(req.object.get('foo')).toBe('bar');
expect(req.original.get('foo')).toBeUndefined();
Expand All @@ -369,7 +369,7 @@ describe('ParseLiveQuery', function () {
silent: true,
});
Parse.Cloud.afterLiveQueryEvent('TestObject', req => {
expect(req.event).toBe('Enter');
expect(req.event).toBe('enter');
expect(req.user).toBeUndefined();
expect(req.object.get('foo')).toBe('bar');
expect(req.original.get('foo')).toBeUndefined();
Expand Down Expand Up @@ -400,7 +400,7 @@ describe('ParseLiveQuery', function () {
silent: true,
});
Parse.Cloud.afterLiveQueryEvent('TestObject', req => {
expect(req.event).toBe('Leave');
expect(req.event).toBe('leave');
expect(req.user).toBeUndefined();
expect(req.object.get('foo')).toBeUndefined();
expect(req.original.get('foo')).toBe('bar');
Expand Down Expand Up @@ -432,7 +432,7 @@ describe('ParseLiveQuery', function () {
silent: true,
});
Parse.Cloud.afterLiveQueryEvent('TestObject', req => {
expect(req.event).toBe('Delete');
expect(req.event).toBe('delete');
expect(req.user).toBeUndefined();
req.object.set('foo', 'bar');
});
Expand Down
13 changes: 7 additions & 6 deletions src/LiveQuery/ParseLiveQueryServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class ParseLiveQueryServer {
return null;
}
res = {
event: 'Delete',
event: 'delete',
sessionToken: client.sessionToken,
object: deletedParseObject,
clients: this.clients.size,
Expand Down Expand Up @@ -275,14 +275,14 @@ class ParseLiveQueryServer {
// Decide event type
let type;
if (isOriginalMatched && isCurrentMatched) {
type = 'Update';
type = 'update';
} else if (isOriginalMatched && !isCurrentMatched) {
type = 'Leave';
type = 'leave';
} else if (!isOriginalMatched && isCurrentMatched) {
if (originalParseObject) {
type = 'Enter';
type = 'enter';
} else {
type = 'Create';
type = 'create';
}
} else {
return null;
Expand Down Expand Up @@ -315,7 +315,8 @@ class ParseLiveQueryServer {
originalParseObject = res.original.toJSON();
originalParseObject.className = res.original.className || className;
}
const functionName = 'push' + message.event;
const functionName =
'push' + message.event.charAt(0).toUpperCase() + message.event.slice(1);
if (client[functionName]) {
client[functionName](requestId, currentParseObject, originalParseObject);
}
Expand Down