ran npm run tdd & generated TDD
This commit is contained in:
10
test/cleanObj/cleanObj.js
Normal file
10
test/cleanObj/cleanObj.js
Normal file
@ -0,0 +1,10 @@
|
||||
module.exports = (obj, keysToKeep = [], childIndicator) => {
|
||||
Object.keys(obj).forEach(key => {
|
||||
if (key === childIndicator) {
|
||||
cleanObj(obj[key], keysToKeep, childIndicator);
|
||||
} else if (!keysToKeep.includes(key)) {
|
||||
delete obj[key];
|
||||
}
|
||||
});
|
||||
return obj;
|
||||
};
|
||||
13
test/cleanObj/cleanObj.test.js
Normal file
13
test/cleanObj/cleanObj.test.js
Normal file
@ -0,0 +1,13 @@
|
||||
const test = require('tape');
|
||||
const cleanObj = require('./cleanObj.js');
|
||||
|
||||
test('Testing cleanObj', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof cleanObj === 'function', 'cleanObj is a Function');
|
||||
//t.deepEqual(cleanObj(args..), 'Expected');
|
||||
//t.equal(cleanObj(args..), 'Expected');
|
||||
//t.false(cleanObj(args..), 'Expected');
|
||||
//t.throws(cleanObj(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
Reference in New Issue
Block a user