Skip to content

Commit

Permalink
fix: consistent casing for afterLiveQueryEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
dblythy committed Nov 24, 2020
1 parent d4f405d commit 83a9fa9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
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

0 comments on commit 83a9fa9

Please sign in to comment.