Skip to content

Commit 3f802d9

Browse files
committed
added sinon.stub to give mock command reply
1 parent e8068c2 commit 3f802d9

File tree

2 files changed

+1
-5
lines changed

2 files changed

+1
-5
lines changed

test/unit/cmap/connection.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,16 +211,12 @@ describe('new Connection()', function () {
211211
hostAddress: server.hostAddress()
212212
};
213213

214-
const serverSpy = sinon.spy(server, 'command');
215214
const connectAsync = promisify(connect);
216215
const connection: Connection = await connectAsync(options);
217216
const commandSpy = sinon.spy(connection, 'command');
218217

219218
await connection.commandAsync(ns('dummy'), { ping: 1 }, {});
220219
expect(commandSpy).to.have.been.calledOnce;
221-
222-
await server.commandAsync(ns('dummy'), { ping: 1 }, {});
223-
expect(serverSpy).to.have.been.calledOnce;
224220
});
225221

226222
it('throws a network error with kBeforeHandshake set to true on timeout before handshake', function (done) {

test/unit/sdam/server.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ describe('Server', () => {
6868

6969
context('when a server is created', function () {
7070
it('calls the command function through commandAsync', async function () {
71-
const serverSpy = sinon.spy(server, 'command');
71+
const serverSpy = sinon.stub(server, 'command').yieldsRight(undefined, { ok: 1 });
7272
await server.commandAsync(ns('dummy'), { ping: 1 }, {});
7373
expect(serverSpy).to.have.been.calledOnce;
7474
});

0 commit comments

Comments
 (0)