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
16 changes: 16 additions & 0 deletions integration/test/ParseLiveQueryTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,20 @@ describe('Parse LiveQuery', () => {
})
await object.save({ foo: 'bar' });
});

it('can subscribe with open event', async (done) => {
const installationId = await Parse.CoreManager.getInstallationController().currentInstallationId();
const client = await Parse.CoreManager.getLiveQueryController().getDefaultLiveQueryClient();
const object = new TestObject();
await object.save();

const query = new Parse.Query(TestObject);
query.equalTo('objectId', object.id);
const subscription = await query.subscribe();
subscription.on('open', (response) => {
assert.equal(response.clientId, client.id);
assert.equal(response.installationId, installationId);
done();
})
});
});
2 changes: 1 addition & 1 deletion src/LiveQueryClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ class LiveQueryClient extends EventEmitter {
if (subscription) {
subscription.subscribed = true;
subscription.subscribePromise.resolve();
subscription.emit(SUBSCRIPTION_EMMITER_TYPES.OPEN, response);
setTimeout(() => subscription.emit(SUBSCRIPTION_EMMITER_TYPES.OPEN, response), 200);
}
break;
case OP_EVENTS.ERROR:
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/LiveQueryClient-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ describe('LiveQueryClient', () => {
});

liveQueryClient._handleWebSocketMessage(event);

jest.runOnlyPendingTimers();
expect(isChecked).toBe(true);
});

Expand Down