Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
baef9a7
Update triggers.js
dblythy Apr 26, 2020
3825b9c
Update Parse.Cloud.js
dblythy Apr 26, 2020
124e082
Update Parse.Cloud.js
dblythy Apr 26, 2020
26288d9
Update triggers.js
dblythy Apr 26, 2020
94aa3ca
Update ParseLiveQueryServer.js
dblythy Apr 26, 2020
a68b9a3
Update triggers.js
dblythy Apr 26, 2020
8cbf3fd
Update triggers.js
dblythy Apr 26, 2020
a4b2873
Update ParseLiveQueryServer.js
dblythy Apr 26, 2020
f34bd0c
Update triggers.js
dblythy Apr 26, 2020
300c17a
Update ParseLiveQueryServer.js
dblythy Apr 26, 2020
9b63500
Update triggers.js
dblythy Apr 26, 2020
46450fd
Update triggers.js
dblythy Apr 26, 2020
4ae7a44
Update triggers.js
dblythy Apr 26, 2020
9514f5e
Update triggers.js
dblythy Apr 26, 2020
6db5da2
Update triggers.js
dblythy Apr 26, 2020
5b22960
Update triggers.js
dblythy Apr 26, 2020
74253c9
Update triggers.js
dblythy Apr 26, 2020
34c8e6c
Update ParseLiveQueryServer.js
dblythy May 1, 2020
6ba2b37
Update ParseLiveQueryServer.js
dblythy May 1, 2020
66a702e
Update triggers.js
dblythy May 1, 2020
fe577a4
Update triggers.js
dblythy May 1, 2020
b3942a7
Update triggers.js
dblythy May 1, 2020
3d8228c
Update triggers.js
dblythy May 1, 2020
339f8ad
Merge pull request #4 from dblythy/dblythy-patch-1
dblythy May 1, 2020
1c3faeb
Update ParseLiveQueryServer.js
dblythy May 1, 2020
41e2973
Update triggers.js
dblythy May 1, 2020
358449a
Update ParseLiveQueryServer.js
dblythy May 1, 2020
24d1f06
Update ParseLiveQueryServer.js
dblythy May 2, 2020
c8a74ea
Update triggers.js
dblythy May 2, 2020
bebc083
Update ParseLiveQueryServer.js
dblythy May 2, 2020
f07b46f
Update triggers.js
dblythy May 2, 2020
39d9717
Update ParseLiveQueryServer.js
dblythy May 2, 2020
6a689f9
Update ParseLiveQueryServer.js
dblythy May 2, 2020
12881f1
Update ParseLiveQueryServer.js
dblythy May 2, 2020
8079b7e
Update ParseLiveQueryServer.spec.js
dblythy May 2, 2020
fe244d6
Merge pull request #7 from dblythy/dblythy-patch-5
dblythy May 2, 2020
fa5e5cb
Update ParseLiveQueryServer.spec.js
dblythy May 2, 2020
c57f958
Update ParseLiveQueryServer.spec.js
dblythy May 2, 2020
9e85f2c
Update ParseLiveQueryServer.spec.js
dblythy May 2, 2020
9c24e26
Update ParseLiveQueryServer.spec.js
dblythy May 2, 2020
d741d4c
Update ParseLiveQueryServer.spec.js
dblythy May 2, 2020
f1e9335
Update ParseLiveQueryServer.js
dblythy May 2, 2020
cab6755
Update ParseLiveQueryServer.js
dblythy May 2, 2020
6c7c167
Merge pull request #3 from dblythy/dblythy-patch-2-1
dblythy May 2, 2020
eae38e9
Update triggers.js
dblythy May 2, 2020
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
62 changes: 31 additions & 31 deletions spec/ParseLiveQueryServer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,15 +285,15 @@ describe('ParseLiveQueryServer', function() {
.catch(done.fail);
});

it('can handle connect command', function() {
it('can handle connect command', async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding await here is fine. Can you add additional tests for this feature? You might have to await in other places.

const parseLiveQueryServer = new ParseLiveQueryServer({});
const parseWebSocket = {
clientId: -1,
};
parseLiveQueryServer._validateKeys = jasmine
.createSpy('validateKeys')
.and.returnValue(true);
parseLiveQueryServer._handleConnect(parseWebSocket, {
await parseLiveQueryServer._handleConnect(parseWebSocket, {
sessionToken: 'token',
});

Expand All @@ -316,7 +316,7 @@ describe('ParseLiveQueryServer', function() {
expect(Client.pushError).toHaveBeenCalled();
});

it('can handle subscribe command with new query', function() {
it('can handle subscribe command with new query', async () => {
const parseLiveQueryServer = new ParseLiveQueryServer({});
// Add mock client
const clientId = 1;
Expand All @@ -338,7 +338,7 @@ describe('ParseLiveQueryServer', function() {
requestId: requestId,
sessionToken: 'sessionToken',
};
parseLiveQueryServer._handleSubscribe(parseWebSocket, request);
await parseLiveQueryServer._handleSubscribe(parseWebSocket, request);

// Make sure we add the subscription to the server
const subscriptions = parseLiveQueryServer.subscriptions;
Expand All @@ -363,7 +363,7 @@ describe('ParseLiveQueryServer', function() {
expect(client.pushSubscribe).toHaveBeenCalledWith(requestId);
});

it('can handle subscribe command with existing query', function() {
it('can handle subscribe command with existing query', async () => {
const parseLiveQueryServer = new ParseLiveQueryServer({});
// Add two mock clients
const clientId = 1;
Expand All @@ -382,7 +382,7 @@ describe('ParseLiveQueryServer', function() {
},
fields: ['test'],
};
addMockSubscription(
await addMockSubscription(
parseLiveQueryServer,
clientId,
requestId,
Expand All @@ -401,7 +401,7 @@ describe('ParseLiveQueryServer', function() {
fields: ['testAgain'],
};
const requestIdAgain = 1;
addMockSubscription(
await addMockSubscription(
parseLiveQueryServer,
clientIdAgain,
requestIdAgain,
Expand Down Expand Up @@ -447,7 +447,7 @@ describe('ParseLiveQueryServer', function() {
expect(Client.pushError).toHaveBeenCalled();
});

it('can handle unsubscribe command without not existed query', function() {
it('can handle unsubscribe command without not existed query', async () => {
const parseLiveQueryServer = new ParseLiveQueryServer({});
// Add mock client
const clientId = 1;
Expand All @@ -462,7 +462,7 @@ describe('ParseLiveQueryServer', function() {
expect(Client.pushError).toHaveBeenCalled();
});

it('can handle unsubscribe command', function() {
it('can handle unsubscribe command', async () => {
const parseLiveQueryServer = new ParseLiveQueryServer({});
// Add mock client
const clientId = 1;
Expand All @@ -472,7 +472,7 @@ describe('ParseLiveQueryServer', function() {
clientId: 1,
};
const requestId = 2;
const subscription = addMockSubscription(
const subscription = await addMockSubscription(
parseLiveQueryServer,
clientId,
requestId,
Expand Down Expand Up @@ -696,7 +696,7 @@ describe('ParseLiveQueryServer', function() {
parseLiveQueryServer._onAfterDelete(message, {});
});

it('can handle object delete command which does not match any subscription', function() {
it('can handle object delete command which does not match any subscription', async () => {
const parseLiveQueryServer = new ParseLiveQueryServer({});
// Make deletedParseObject
const parseObject = new Parse.Object(testClassName);
Expand All @@ -714,7 +714,7 @@ describe('ParseLiveQueryServer', function() {
addMockClient(parseLiveQueryServer, clientId);
// Add mock subscription
const requestId = 2;
addMockSubscription(parseLiveQueryServer, clientId, requestId);
await addMockSubscription(parseLiveQueryServer, clientId, requestId);
const client = parseLiveQueryServer.clients.get(clientId);
// Mock _matchesSubscription to return not matching
parseLiveQueryServer._matchesSubscription = function() {
Expand All @@ -729,7 +729,7 @@ describe('ParseLiveQueryServer', function() {
expect(client.pushDelete).not.toHaveBeenCalled();
});

it('can handle object delete command which matches some subscriptions', function(done) {
it('can handle object delete command which matches some subscriptions', async (done) => {
const parseLiveQueryServer = new ParseLiveQueryServer({});
// Make deletedParseObject
const parseObject = new Parse.Object(testClassName);
Expand All @@ -746,7 +746,7 @@ describe('ParseLiveQueryServer', function() {
addMockClient(parseLiveQueryServer, clientId);
// Add mock subscription
const requestId = 2;
addMockSubscription(parseLiveQueryServer, clientId, requestId);
await addMockSubscription(parseLiveQueryServer, clientId, requestId);
const client = parseLiveQueryServer.clients.get(clientId);
// Mock _matchesSubscription to return matching
parseLiveQueryServer._matchesSubscription = function() {
Expand All @@ -765,15 +765,15 @@ describe('ParseLiveQueryServer', function() {
}, jasmine.ASYNC_TEST_WAIT_TIME);
});

it('has no subscription and can handle object save command', function() {
it('has no subscription and can handle object save command', async () => {
const parseLiveQueryServer = new ParseLiveQueryServer({});
// Make mock request message
const message = generateMockMessage();
// Make sure we do not crash in this case
parseLiveQueryServer._onAfterSave(message);
});

it('can handle object save command which does not match any subscription', function(done) {
it('can handle object save command which does not match any subscription', async (done) => {
const parseLiveQueryServer = new ParseLiveQueryServer({});
// Make mock request message
const message = generateMockMessage();
Expand All @@ -782,7 +782,7 @@ describe('ParseLiveQueryServer', function() {
const client = addMockClient(parseLiveQueryServer, clientId);
// Add mock subscription
const requestId = 2;
addMockSubscription(parseLiveQueryServer, clientId, requestId);
await addMockSubscription(parseLiveQueryServer, clientId, requestId);
// Mock _matchesSubscription to return not matching
parseLiveQueryServer._matchesSubscription = function() {
return false;
Expand All @@ -804,7 +804,7 @@ describe('ParseLiveQueryServer', function() {
}, jasmine.ASYNC_TEST_WAIT_TIME);
});

it('can handle object enter command which matches some subscriptions', function(done) {
it('can handle object enter command which matches some subscriptions', async (done) => {
const parseLiveQueryServer = new ParseLiveQueryServer({});
// Make mock request message
const message = generateMockMessage(true);
Expand All @@ -813,7 +813,7 @@ describe('ParseLiveQueryServer', function() {
const client = addMockClient(parseLiveQueryServer, clientId);
// Add mock subscription
const requestId = 2;
addMockSubscription(parseLiveQueryServer, clientId, requestId);
await addMockSubscription(parseLiveQueryServer, clientId, requestId);
// Mock _matchesSubscription to return matching
// In order to mimic a enter, we need original match return false
// and the current match return true
Expand Down Expand Up @@ -841,7 +841,7 @@ describe('ParseLiveQueryServer', function() {
}, jasmine.ASYNC_TEST_WAIT_TIME);
});

it('can handle object update command which matches some subscriptions', function(done) {
it('can handle object update command which matches some subscriptions', async (done) => {
const parseLiveQueryServer = new ParseLiveQueryServer({});
// Make mock request message
const message = generateMockMessage(true);
Expand All @@ -850,7 +850,7 @@ describe('ParseLiveQueryServer', function() {
const client = addMockClient(parseLiveQueryServer, clientId);
// Add mock subscription
const requestId = 2;
addMockSubscription(parseLiveQueryServer, clientId, requestId);
await addMockSubscription(parseLiveQueryServer, clientId, requestId);
// Mock _matchesSubscription to return matching
parseLiveQueryServer._matchesSubscription = function(parseObject) {
if (!parseObject) {
Expand All @@ -874,7 +874,7 @@ describe('ParseLiveQueryServer', function() {
}, jasmine.ASYNC_TEST_WAIT_TIME);
});

it('can handle object leave command which matches some subscriptions', function(done) {
it('can handle object leave command which matches some subscriptions', async (done) => {
const parseLiveQueryServer = new ParseLiveQueryServer({});
// Make mock request message
const message = generateMockMessage(true);
Expand All @@ -883,7 +883,7 @@ describe('ParseLiveQueryServer', function() {
const client = addMockClient(parseLiveQueryServer, clientId);
// Add mock subscription
const requestId = 2;
addMockSubscription(parseLiveQueryServer, clientId, requestId);
await addMockSubscription(parseLiveQueryServer, clientId, requestId);
// Mock _matchesSubscription to return matching
// In order to mimic a leave, we need original match return true
// and the current match return false
Expand Down Expand Up @@ -911,7 +911,7 @@ describe('ParseLiveQueryServer', function() {
}, jasmine.ASYNC_TEST_WAIT_TIME);
});

it('can handle update command with original object', function(done) {
it('can handle update command with original object', async (done) => {
jasmine.restoreLibrary('../lib/LiveQuery/Client', 'Client');
const Client = require('../lib/LiveQuery/Client').Client;
const parseLiveQueryServer = new ParseLiveQueryServer({});
Expand All @@ -930,7 +930,7 @@ describe('ParseLiveQueryServer', function() {
// Add mock subscription
const requestId = 2;

addMockSubscription(
await addMockSubscription(
parseLiveQueryServer,
clientId,
requestId,
Expand Down Expand Up @@ -961,7 +961,7 @@ describe('ParseLiveQueryServer', function() {
}, jasmine.ASYNC_TEST_WAIT_TIME);
});

it('can handle object create command which matches some subscriptions', function(done) {
it('can handle object create command which matches some subscriptions', async (done) => {
const parseLiveQueryServer = new ParseLiveQueryServer({});
// Make mock request message
const message = generateMockMessage();
Expand All @@ -970,7 +970,7 @@ describe('ParseLiveQueryServer', function() {
const client = addMockClient(parseLiveQueryServer, clientId);
// Add mock subscription
const requestId = 2;
addMockSubscription(parseLiveQueryServer, clientId, requestId);
await addMockSubscription(parseLiveQueryServer, clientId, requestId);
// Mock _matchesSubscription to return matching
parseLiveQueryServer._matchesSubscription = function(parseObject) {
if (!parseObject) {
Expand All @@ -994,7 +994,7 @@ describe('ParseLiveQueryServer', function() {
}, jasmine.ASYNC_TEST_WAIT_TIME);
});

it('can handle create command with fields', function(done) {
it('can handle create command with fields', async (done) => {
jasmine.restoreLibrary('../lib/LiveQuery/Client', 'Client');
const Client = require('../lib/LiveQuery/Client').Client;
const parseLiveQueryServer = new ParseLiveQueryServer({});
Expand All @@ -1019,7 +1019,7 @@ describe('ParseLiveQueryServer', function() {
},
fields: ['test'],
};
addMockSubscription(
await addMockSubscription(
parseLiveQueryServer,
clientId,
requestId,
Expand Down Expand Up @@ -1842,7 +1842,7 @@ describe('ParseLiveQueryServer', function() {
return client;
}

function addMockSubscription(
async function addMockSubscription(
parseLiveQueryServer,
clientId,
requestId,
Expand Down Expand Up @@ -1870,7 +1870,7 @@ describe('ParseLiveQueryServer', function() {
requestId: requestId,
sessionToken: 'sessionToken',
};
parseLiveQueryServer._handleSubscribe(parseWebSocket, request);
await parseLiveQueryServer._handleSubscribe(parseWebSocket, request);

// Make mock subscription
const subscription = parseLiveQueryServer.subscriptions
Expand Down
Loading