Skip to content

Commit 4bfeb66

Browse files
committed
check call count
1 parent 35f723b commit 4bfeb66

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

test/integration/initial-dns-seedlist-discovery/dns_seedlist.test.ts

+13-8
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ class DNSSomethingError extends Error {
1616
}
1717

1818
const CONNECTION_STRING = `mongodb+srv://test1.test.build.10gen.cc`;
19-
// 27018 localhost.test.build.10gen.cc.
20-
// 27017 localhost.test.build.10gen.cc.
2119

2220
describe('DNS timeout errors', () => {
2321
let client: MongoClient;
22+
let stub;
2423

2524
beforeEach(async function () {
2625
client = new MongoClient(CONNECTION_STRING, { serverSelectionTimeoutMS: 2000, tls: false });
2726
});
2827

2928
afterEach(async function () {
29+
stub = undefined;
3030
sinon.restore();
3131
await client.close();
3232
});
@@ -40,7 +40,7 @@ describe('DNS timeout errors', () => {
4040

4141
describe('when SRV record look up times out', () => {
4242
beforeEach(() => {
43-
sinon
43+
stub = sinon
4444
.stub(dns.promises, 'resolveSrv')
4545
.onFirstCall()
4646
.rejects(new DNSTimeoutError())
@@ -54,12 +54,13 @@ describe('DNS timeout errors', () => {
5454

5555
it('retries timeout error', metadata, async () => {
5656
await client.connect();
57+
expect(stub).to.have.been.calledTwice;
5758
});
5859
});
5960

6061
describe('when TXT record look up times out', () => {
6162
beforeEach(() => {
62-
sinon
63+
stub = sinon
6364
.stub(dns.promises, 'resolveTxt')
6465
.onFirstCall()
6566
.rejects(new DNSTimeoutError())
@@ -73,12 +74,13 @@ describe('DNS timeout errors', () => {
7374

7475
it('retries timeout error', metadata, async () => {
7576
await client.connect();
77+
expect(stub).to.have.been.calledTwice;
7678
});
7779
});
7880

7981
describe('when SRV record look up times out twice', () => {
8082
beforeEach(() => {
81-
sinon
83+
stub = sinon
8284
.stub(dns.promises, 'resolveSrv')
8385
.onFirstCall()
8486
.rejects(new DNSTimeoutError())
@@ -100,7 +102,7 @@ describe('DNS timeout errors', () => {
100102

101103
describe('when TXT record look up times out twice', () => {
102104
beforeEach(() => {
103-
sinon
105+
stub = sinon
104106
.stub(dns.promises, 'resolveTxt')
105107
.onFirstCall()
106108
.rejects(new DNSTimeoutError())
@@ -117,12 +119,13 @@ describe('DNS timeout errors', () => {
117119
it('throws timeout error', metadata, async () => {
118120
const error = await client.connect().catch(error => error);
119121
expect(error).to.be.instanceOf(DNSTimeoutError);
122+
expect(stub).to.have.been.calledTwice;
120123
});
121124
});
122125

123126
describe('when SRV record look up throws a non-timeout error', () => {
124127
beforeEach(() => {
125-
sinon
128+
stub = sinon
126129
.stub(dns.promises, 'resolveSrv')
127130
.onFirstCall()
128131
.rejects(new DNSSomethingError())
@@ -137,12 +140,13 @@ describe('DNS timeout errors', () => {
137140
it('throws that error', metadata, async () => {
138141
const error = await client.connect().catch(error => error);
139142
expect(error).to.be.instanceOf(DNSSomethingError);
143+
expect(stub).to.have.been.calledOnce;
140144
});
141145
});
142146

143147
describe('when TXT record look up throws a non-timeout error', () => {
144148
beforeEach(() => {
145-
sinon
149+
stub = sinon
146150
.stub(dns.promises, 'resolveTxt')
147151
.onFirstCall()
148152
.rejects(new DNSSomethingError())
@@ -157,6 +161,7 @@ describe('DNS timeout errors', () => {
157161
it('throws that error', metadata, async () => {
158162
const error = await client.connect().catch(error => error);
159163
expect(error).to.be.instanceOf(DNSSomethingError);
164+
expect(stub).to.have.been.calledOnce;
160165
});
161166
});
162167
});

0 commit comments

Comments
 (0)