|
@@ -1,13 +1,13 @@
|
|
const { expect } = require('chai');
|
|
const { expect } = require('chai');
|
|
-const Client = require('../../../src/models/client');
|
|
|
|
-const Realm = require('../../../src/models/realm');
|
|
|
|
-const checkBrokenConnectionsBuilder = require('../../../src/services/checkBrokenConnections');
|
|
|
|
|
|
+const { Client } = require('../../../dist/src/models/client');
|
|
|
|
+const { Realm } = require('../../../dist/src/models/realm');
|
|
|
|
+const { CheckBrokenConnections } = require('../../../dist/src/services/checkBrokenConnections');
|
|
|
|
|
|
describe('checkBrokenConnections service', () => {
|
|
describe('checkBrokenConnections service', () => {
|
|
it('should remove client after 2 checks', (done) => {
|
|
it('should remove client after 2 checks', (done) => {
|
|
const realm = new Realm();
|
|
const realm = new Realm();
|
|
- const doubleCheckTime = 55;//~ equals to checkBrokenConnections.CHECK_INTERVAL * 2
|
|
|
|
- const checkBrokenConnections = checkBrokenConnectionsBuilder({ realm, config: { alive_timeout: doubleCheckTime }, checkInterval: 30 });
|
|
|
|
|
|
+ const doubleCheckTime = 55;//~ equals to checkBrokenConnections.checkInterval * 2
|
|
|
|
+ const checkBrokenConnections = new CheckBrokenConnections({ realm, config: { alive_timeout: doubleCheckTime }, checkInterval: 30 });
|
|
const client = new Client({ id: 'id', token: '' });
|
|
const client = new Client({ id: 'id', token: '' });
|
|
realm.setClient(client, 'id');
|
|
realm.setClient(client, 'id');
|
|
|
|
|
|
@@ -17,13 +17,13 @@ describe('checkBrokenConnections service', () => {
|
|
expect(realm.getClientById('id')).to.be.undefined;
|
|
expect(realm.getClientById('id')).to.be.undefined;
|
|
checkBrokenConnections.stop();
|
|
checkBrokenConnections.stop();
|
|
done();
|
|
done();
|
|
- }, checkBrokenConnections.CHECK_INTERVAL * 2 + 3);
|
|
|
|
|
|
+ }, checkBrokenConnections.checkInterval * 2 + 10);
|
|
});
|
|
});
|
|
|
|
|
|
it('should remove client after 1 ping', (done) => {
|
|
it('should remove client after 1 ping', (done) => {
|
|
const realm = new Realm();
|
|
const realm = new Realm();
|
|
- const doubleCheckTime = 55;//~ equals to checkBrokenConnections.CHECK_INTERVAL * 2
|
|
|
|
- const checkBrokenConnections = checkBrokenConnectionsBuilder({ realm, config: { alive_timeout: doubleCheckTime }, checkInterval: 30 });
|
|
|
|
|
|
+ const doubleCheckTime = 55;//~ equals to checkBrokenConnections.checkInterval * 2
|
|
|
|
+ const checkBrokenConnections = new CheckBrokenConnections({ realm, config: { alive_timeout: doubleCheckTime }, checkInterval: 30 });
|
|
const client = new Client({ id: 'id', token: '' });
|
|
const client = new Client({ id: 'id', token: '' });
|
|
realm.setClient(client, 'id');
|
|
realm.setClient(client, 'id');
|
|
|
|
|
|
@@ -37,7 +37,7 @@ describe('checkBrokenConnections service', () => {
|
|
expect(realm.getClientById('id')).to.be.undefined;
|
|
expect(realm.getClientById('id')).to.be.undefined;
|
|
checkBrokenConnections.stop();
|
|
checkBrokenConnections.stop();
|
|
done();
|
|
done();
|
|
- }, checkBrokenConnections.CHECK_INTERVAL * 2 + 10);
|
|
|
|
- }, checkBrokenConnections.CHECK_INTERVAL);
|
|
|
|
|
|
+ }, checkBrokenConnections.checkInterval * 2 + 10);
|
|
|
|
+ }, checkBrokenConnections.checkInterval);
|
|
});
|
|
});
|
|
});
|
|
});
|