-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
topology.test.js
31 lines (29 loc) · 944 Bytes
/
topology.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
'use strict';
const { expect } = require('chai');
describe('Topology', function () {
it('should correctly track states of a topology', {
metadata: { requires: { apiVersion: false, topology: '!load-balanced' } }, // apiVersion not supported by newTopology()
test: function (done) {
const topology = this.configuration.newTopology();
const states = [];
topology.on('stateChanged', (_, newState) => states.push(newState));
topology.connect(err => {
try {
expect(err).to.not.exist;
} catch (error) {
done(error);
}
topology.close({}, err => {
try {
expect(err).to.not.exist;
expect(topology.isDestroyed()).to.be.true;
expect(states).to.eql(['connecting', 'connected', 'closing', 'closed']);
done();
} catch (error) {
done(error);
}
});
});
}
});
});