Skip to content
Merged
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
40 changes: 36 additions & 4 deletions packages/ddp-client/__tests__/Connection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,15 @@ it('should handle reconnecting', async () => {
server,
Comment thread
sampaiodiego marked this conversation as resolved.
jest.advanceTimersByTimeAsync(200),
new Promise((resolve) => connection.once('reconnecting', () => resolve(undefined))),
new Promise((resolve) => connection.once('connection', (data) => resolve(data))),
new Promise((resolve) => {
const handler = (status: string) => {
if (status === 'connected') {
connection.off('connection', handler);
resolve(status);
}
};
connection.on('connection', handler);
}),
);

expect(connection.status).toBe('connected');
Expand Down Expand Up @@ -268,7 +276,15 @@ it('should reset retryCount on a successful connection so subsequent drops can r
server,
jest.advanceTimersByTimeAsync(200),
new Promise((resolve) => connection.once('reconnecting', () => resolve(undefined))),
new Promise((resolve) => connection.once('connection', (data) => resolve(data))),
new Promise((resolve) => {
const handler = (status: string) => {
if (status === 'connected') {
connection.off('connection', handler);
resolve(status);
}
};
connection.on('connection', handler);
}),
);
jest.useRealTimers();
expect(connection.status).toBe('connected');
Expand All @@ -286,7 +302,15 @@ it('should reset retryCount on a successful connection so subsequent drops can r
server,
jest.advanceTimersByTimeAsync(200),
new Promise((resolve) => connection.once('reconnecting', () => resolve(undefined))),
new Promise((resolve) => connection.once('connection', (data) => resolve(data))),
new Promise((resolve) => {
const handler = (status: string) => {
if (status === 'connected') {
connection.off('connection', handler);
resolve(status);
}
};
connection.on('connection', handler);
}),
);
jest.useRealTimers();
expect(connection.status).toBe('connected');
Expand Down Expand Up @@ -316,7 +340,15 @@ it('should ignore a stale ws.onclose that fires after the socket has been replac
server,
jest.advanceTimersByTimeAsync(200),
new Promise((resolve) => connection.once('reconnecting', () => resolve(undefined))),
new Promise((resolve) => connection.once('connection', (data) => resolve(data))),
new Promise((resolve) => {
const handler = (status: string) => {
if (status === 'connected') {
connection.off('connection', handler);
resolve(status);
}
};
connection.on('connection', handler);
}),
);

expect(connection.status).toBe('connected');
Expand Down
Loading