rittenhop-dev/versions/5.94.2/node_modules/require-dir/test/mapValue.js

31 lines
685 B
JavaScript
Raw Normal View History

2024-09-23 19:40:12 -04:00
var assert = require('assert');
var requireDir = require('..');
var mapper = function(v, f) {
if (typeof v === 'string') return v.toUpperCase();
return v;
};
// first test without recursing:
assert.deepEqual(requireDir('./recurse', { mapValue: mapper }), {
a: 'A',
});
// then test with recursing:
assert.deepEqual(requireDir('./recurse', { recurse: true, mapValue: mapper }), {
a: 'A',
b: {
'1': {
foo: 'FOO',
bar: 'BAR',
},
'2': {} // note how the directory is always returned
},
c: {
'3': 3
},
// note that node_modules was explicitly ignored
});
console.log('mapValue tests passed.');