Skip to content

Commit

Permalink
Only run tests on correct node versions
Browse files Browse the repository at this point in the history
  • Loading branch information
scagood committed Aug 22, 2023
1 parent 8b2eb8b commit 7b83cee
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
11 changes: 9 additions & 2 deletions test/mutability.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ var assert = require('assert');
var traverse = require('../');
var deepEqual = require('./lib/deep_equal');

function isNodeGTE6() {
return (/v([6789]|1\d+)\.\d+\.\d+/).test(process.version);
}
function isNodeGTE4() {
return (/v([456789]|1\d+)\.\d+\.\d+/).test(process.version);
}

test('mutate', function (t) {
var obj = { a: 1, b: 2, c: [3, 4] };
var res = traverse(obj).forEach(function (x) {
Expand Down Expand Up @@ -78,7 +85,7 @@ test('cloneT', function (t) {
});

test('cloneBuffer', function (t) {
if (Buffer && Buffer.from) {
if (isNodeGTE6()) {
var obj = Buffer.from('a');
var res = traverse.clone(obj);

Expand All @@ -95,7 +102,7 @@ test('cloneBuffer', function (t) {

/* global Uint8Array */
test('cloneTypedArray', function (t) {
if (Uint8Array && Uint8Array.from) {
if (isNodeGTE4()) {
var obj = Uint8Array.from([1]);
var res = traverse.clone(obj);

Expand Down
11 changes: 9 additions & 2 deletions test/typed-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@
var test = require('tape');
var traverse = require('../');

function isNodeGTE6() {
return (/v([6789]|1\d+)\.\d+\.\d+/).test(process.version);
}
function isNodeGTE4() {
return (/v([456789]|1\d+)\.\d+\.\d+/).test(process.version);
}

test('traverse an Buffer', function (t) {
if (Buffer && Buffer.from) {
if (isNodeGTE6()) {
var obj = Buffer.from('test');
var results = traverse(obj).map(function () {});
t.same(results, obj);
Expand All @@ -14,7 +21,7 @@ test('traverse an Buffer', function (t) {

/* global Uint8Array */
test('traverse an UInt8Array', function (t) {
if (Uint8Array && Uint8Array.from) {
if (isNodeGTE4()) {
var obj = Uint8Array.from('test');
var results = traverse(obj).map(function () {});
t.same(results, obj);
Expand Down

0 comments on commit 7b83cee

Please sign in to comment.