Skip to content

Commit

Permalink
removed .bind
Browse files Browse the repository at this point in the history
  • Loading branch information
malikj2000 committed Jun 29, 2023
1 parent a055b40 commit 14ab51e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 22 deletions.
4 changes: 2 additions & 2 deletions test/unit/operations/find.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('FindOperation', function () {
it('should build basic find command with filter', async () => {
const findOperation = new FindOperation(undefined, namespace, filter);
const stub = sinon.stub(server, 'command').yieldsRight();
await findOperation.execute.bind(findOperation)(server, undefined);
await findOperation.execute(server, undefined);
expect(stub).to.have.been.calledOnceWith(namespace, {
find: namespace.collection,
filter
Expand All @@ -55,7 +55,7 @@ describe('FindOperation', function () {
};
const findOperation = new FindOperation(undefined, namespace, {}, options);
const stub = sinon.stub(server, 'command').yieldsRight();
await findOperation.execute.bind(findOperation)(server, undefined);
await findOperation.execute(server, undefined);
expect(stub).to.have.been.calledOnceWith(
namespace,
sinon.match.has('oplogReplay', options.oplogReplay)
Expand Down
22 changes: 8 additions & 14 deletions test/unit/operations/get_more.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('GetMoreOperation', function () {
maxTimeMS: 500
};

await operation.execute.bind(operation)(server, undefined);
await operation.execute(server, undefined);
expect(stub.calledOnce).to.be.true;
const call = stub.getCall(0);
expect(call.args[0]).to.equal(namespace);
Expand Down Expand Up @@ -108,7 +108,7 @@ describe('GetMoreOperation', function () {
it('should build basic getMore command with cursorId and collection', async () => {
const getMoreOperation = new GetMoreOperation(namespace, cursorId, server, {});
const stub = sinon.stub(server, 'command').yieldsRight();
await getMoreOperation.execute.bind(getMoreOperation)(server, undefined);
await getMoreOperation.execute(server, undefined);
expect(stub).to.have.been.calledOnceWith(namespace, {
getMore: cursorId,
collection: namespace.collection
Expand All @@ -121,7 +121,7 @@ describe('GetMoreOperation', function () {
};
const getMoreOperation = new GetMoreOperation(namespace, cursorId, server, options);
const stub = sinon.stub(server, 'command').yieldsRight();
await getMoreOperation.execute.bind(getMoreOperation)(server, undefined);
await getMoreOperation.execute(server, undefined);
expect(stub).to.have.been.calledOnceWith(
namespace,
sinon.match.has('batchSize', options.batchSize)
Expand All @@ -134,7 +134,7 @@ describe('GetMoreOperation', function () {
};
const getMoreOperation = new GetMoreOperation(namespace, cursorId, server, options);
const stub = sinon.stub(server, 'command').yieldsRight();
await getMoreOperation.execute.bind(getMoreOperation)(server, undefined);
await getMoreOperation.execute(server, undefined);
expect(stub).to.have.been.calledOnceWith(
namespace,
sinon.match.has('maxTimeMS', options.maxAwaitTimeMS)
Expand Down Expand Up @@ -192,7 +192,7 @@ describe('GetMoreOperation', function () {
};
const operation = new GetMoreOperation(namespace, cursorId, server, optionsWithComment);
const stub = sinon.stub(server, 'command').yieldsRight();
await operation.execute.bind(operation)(server, undefined);
await operation.execute(server, undefined);
expect(stub).to.have.been.calledOnceWith(namespace, getMore);
});
}
Expand All @@ -215,9 +215,7 @@ describe('GetMoreOperation', function () {
server,
options
);
const error = await getMoreOperation.execute
.bind(getMoreOperation)(server, undefined)
.catch(error => error);
const error = await getMoreOperation.execute(server, undefined).catch(error => error);
expect(error).to.be.instanceOf(MongoRuntimeError);
});

Expand All @@ -228,9 +226,7 @@ describe('GetMoreOperation', function () {
server,
options
);
const error = await getMoreOperation.execute
.bind(getMoreOperation)(server, undefined)
.catch(error => error);
const error = await getMoreOperation.execute(server, undefined).catch(error => error);
expect(error).to.be.instanceOf(MongoRuntimeError);
});

Expand All @@ -241,9 +237,7 @@ describe('GetMoreOperation', function () {
server,
options
);
const error = await getMoreOperation.execute
.bind(getMoreOperation)(server, undefined)
.catch(error => error);
const error = await getMoreOperation.execute(server, undefined).catch(error => error);
expect(error).to.be.instanceOf(MongoRuntimeError);
});
});
Expand Down
10 changes: 4 additions & 6 deletions test/unit/operations/kill_cursors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ describe('class KillCursorsOperation', () => {
options
) as any;

const error = await killCursorsOperation.execute
.bind(killCursorsOperation)(differentServer, undefined)
const error = await killCursorsOperation
.execute(differentServer, undefined)
.catch(error => error);

expect(error).to.be.instanceOf(MongoRuntimeError);
Expand All @@ -79,9 +79,7 @@ describe('class KillCursorsOperation', () => {
options
) as any;

const error = await killCursorsOperation.execute
.bind(killCursorsOperation)(server, undefined)
.catch(error => error);
const error = await killCursorsOperation.execute(server, undefined).catch(error => error);

expect(error).to.be.instanceOf(MongoRuntimeError);
});
Expand All @@ -94,7 +92,7 @@ describe('class KillCursorsOperation', () => {
options
) as any;
const stub = sinon.stub(server, 'command').yieldsRight();
await killCursorsOperation.execute.bind(killCursorsOperation)(server, undefined);
await killCursorsOperation.execute(server, undefined);
expect(stub).to.have.been.calledOnceWith(namespace, {
killCursors: namespace.collection,
cursors: [cursorId]
Expand Down

0 comments on commit 14ab51e

Please sign in to comment.