Skip to content

Commit 32e0613

Browse files
Added node version handling for NaN w payload test cases
1 parent 222da53 commit 32e0613

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

test/node/bson_corpus.spec.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
const Buffer = require('buffer').Buffer;
55
const BSON = require('../register-bson');
6+
const { getNodeMajor } = require('./tools/utils');
67
const BSONError = BSON.BSONError;
78
const EJSON = BSON.EJSON;
89

@@ -121,6 +122,10 @@ describe('BSON Corpus', function () {
121122
describe('valid-bson', function () {
122123
for (const v of valid) {
123124
it(v.description, function () {
125+
if (v.description === 'NaN with payload' && getNodeMajor() < 10) {
126+
this.skip();
127+
}
128+
124129
if (
125130
v.description === 'All BSON types' &&
126131
scenario._filename === 'multi-type-deprecated'

test/node/double_tests.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
const BSON = require('../register-bson');
4+
const { getNodeMajor } = require('./tools/utils');
45
const Double = BSON.Double;
56

67
describe('Double', function () {
@@ -64,7 +65,10 @@ describe('Double', function () {
6465
expect(Number.isNaN(newVal)).to.equal(true);
6566
});
6667

67-
it('NaN with payload', () => {
68+
it('NaN with payload', function () {
69+
if (getNodeMajor() < 10) {
70+
this.skip();
71+
}
6872
let buffer = Buffer.from('120000000000F87F', 'hex');
6973
let value = buffer.readDoubleLE(0);
7074
let serializedDouble = BSON.serialize({ d: new Double(value) });

test/node/tools/utils.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ exports.isNode6 = function () {
158158
return process.version.split('.')[0] === 'v6';
159159
};
160160

161+
exports.getNodeMajor = function () {
162+
// eslint-disable-next-line no-undef
163+
return Number(process.versions.node.split('.')[0]);
164+
};
165+
161166
const getSymbolFrom = function (target, symbolName, assertExists) {
162167
if (assertExists == null) assertExists = true;
163168

0 commit comments

Comments
 (0)