Skip to content

Commit 62302b7

Browse files
test fix
1 parent cc1f36c commit 62302b7

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

test/integration/node-specific/bson-options/utf8_validation.test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ describe('class MongoDBResponse', () => {
160160
);
161161
});
162162

163-
describe.only('utf8 validation with cursors', function () {
163+
describe('utf8 validation with cursors', function () {
164164
let client: MongoClient;
165165
let collection: Collection;
166166

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

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

0 commit comments

Comments
 (0)