Skip to content

Commit

Permalink
test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
baileympearson committed Aug 30, 2024
1 parent cc1f36c commit 62302b7
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ describe('class MongoDBResponse', () => {
);
});

describe.only('utf8 validation with cursors', function () {
describe('utf8 validation with cursors', function () {
let client: MongoClient;
let collection: Collection;

Expand All @@ -173,8 +173,12 @@ describe.only('utf8 validation with cursors', function () {
await collection.deleteMany({});

const stub = sinon.stub(net.Socket.prototype, 'write').callsFake(function (...args) {
if (args[0].toString('hex').includes('c3a9')) {
const buffer = Buffer.from(args[0].toString('hex').replace('c3a9', 'c301'), 'hex');
const providedBuffer = args[0].toString('hex');
if (providedBuffer.includes('c3a9')) {
if (providedBuffer.split('c3a9').length !== 2) {
throw new Error('received buffer more than one `c3a9` sequences. or perhaps none?');
}
const buffer = Buffer.from(providedBuffer.replace('c3a9', 'c301'), 'hex');
const result = stub.wrappedMethod.apply(this, [buffer]);
sinon.restore();
return result;
Expand Down

0 comments on commit 62302b7

Please sign in to comment.