Skip to content

Commit 8fcf60a

Browse files
committed
fix: tests running after deps upgrade
1 parent 5754a6c commit 8fcf60a

File tree

5 files changed

+6
-47
lines changed

5 files changed

+6
-47
lines changed

src/Meteor.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const Meteor = {
5454
return {
5555
connected: !!this._reactiveDict.get('connected'),
5656
status: Data.ddp ? Data.ddp.status : 'disconnected',
57+
hasDdp: !!Data.ddp,
5758
//retryCount: 0
5859
//retryTime:
5960
//reason:

test/hooks/mockServer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export async function mochaGlobalSetup() {
2525
}
2626
};
2727

28-
console.debug('mockserver wait for connected...')
28+
console.debug('mockserver wait for connected...');
2929
await new Promise((resolve) => {
3030
_server.on('connection', (socket) => {
3131
console.debug('mockserver listening');
@@ -35,7 +35,7 @@ export async function mochaGlobalSetup() {
3535
resolve();
3636
});
3737
});
38-
console.debug('end of setup')
38+
console.debug('end of setup');
3939
}
4040

4141
export async function mochaGlobalTeardown() {

test/src/Collection.tests.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ describe('Collection', function () {
160160
foo: 'bar',
161161
_version: 1,
162162
});
163-
console.debug(server())
164163
server().message(null);
165164
done();
166165
});

test/src/Meteor.tests.js

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect } from 'chai';
22
import Meteor from '../../src/Meteor';
3-
import { awaitDisconnected, stub, restoreAll } from '../testHelpers';
3+
import { stub, restoreAll, asyncTimeout } from '../testHelpers';
44
import DDP from '../../lib/ddp';
55

66
describe('Meteor - integration', function () {
@@ -16,38 +16,6 @@ describe('Meteor - integration', function () {
1616
});
1717

1818
describe(Meteor.connect.name, () => {
19-
before(awaitDisconnected);
20-
21-
it('requires manual connect if autoConnect is set to false', function (done) {
22-
this.timeout(3000);
23-
expect(Meteor.getData().ddp.status).to.equal('disconnected');
24-
stub(DDP.prototype, 'on', () => {});
25-
let connectCalled = 0;
26-
stub(DDP.prototype, 'connect', () => {
27-
done(new Error('should not automatically call connect'));
28-
});
29-
30-
const AsyncStorage = {
31-
getItem: async () => {},
32-
setItem: async () => {},
33-
removeItem: async () => {},
34-
};
35-
36-
const endpoint = `ws://localhost:3000/websocket`;
37-
Meteor.connect(endpoint, {
38-
AsyncStorage,
39-
NetInfo: null,
40-
autoConnect: false,
41-
});
42-
43-
// let's wait some time to make sure no internals
44-
// unintentionally call ddp.connect before we do
45-
setTimeout(() => {
46-
expect(Meteor.getData().ddp.status).to.equal('disconnected');
47-
done();
48-
}, 2900);
49-
});
50-
5119
it('allows to bypass NetInfo', (done) => {
5220
stub(DDP.prototype, 'on', () => {});
5321
stub(DDP.prototype, 'connect', done);

test/testHelpers.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,8 @@ export const restoreAll = () => {
3838
});
3939
};
4040

41-
export const awaitDisconnected = async () => {
42-
Meteor.disconnect();
43-
await new Promise((resolve) => {
44-
let timer = setInterval(() => {
45-
if (Meteor.status().status === 'disconnected') {
46-
clearInterval(timer);
47-
resolve();
48-
}
49-
}, 100);
50-
});
51-
};
41+
export const asyncTimeout = (ms) =>
42+
new Promise((resolve) => setTimeout(resolve, ms));
5243

5344
export const props = (obj) => {
5445
let p = [];

0 commit comments

Comments
 (0)