diff --git a/test/integration/node-specific/bson-options/utf8_validation.test.ts b/test/integration/node-specific/bson-options/utf8_validation.test.ts index cc57c7ce7a..0089ea561f 100644 --- a/test/integration/node-specific/bson-options/utf8_validation.test.ts +++ b/test/integration/node-specific/bson-options/utf8_validation.test.ts @@ -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; @@ -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;