From 7c805e941a57a7eeb2bdd07974dfb18dd1469207 Mon Sep 17 00:00:00 2001 From: King Date: Thu, 11 Jan 2018 05:27:49 -0500 Subject: [PATCH] ran npm tdd --- test/decapitalize/decapitalize.js | 2 ++ test/decapitalize/decapitalize.test.js | 13 +++++++++++++ test/flattenDepth/flattenDepth.js | 4 ++++ test/flattenDepth/flattenDepth.test.js | 13 +++++++++++++ test/isObject/isObject.js | 1 + test/isObject/isObject.test.js | 13 +++++++++++++ 6 files changed, 46 insertions(+) create mode 100644 test/decapitalize/decapitalize.js create mode 100644 test/decapitalize/decapitalize.test.js create mode 100644 test/flattenDepth/flattenDepth.js create mode 100644 test/flattenDepth/flattenDepth.test.js create mode 100644 test/isObject/isObject.js create mode 100644 test/isObject/isObject.test.js diff --git a/test/decapitalize/decapitalize.js b/test/decapitalize/decapitalize.js new file mode 100644 index 000000000..6e84e5d6e --- /dev/null +++ b/test/decapitalize/decapitalize.js @@ -0,0 +1,2 @@ +module.exports = decapitalize = ([first, ...rest], upperRest = false) => +first.toLowerCase() + (upperRest ? rest.join('').toUpperCase() : rest.join('')); \ No newline at end of file diff --git a/test/decapitalize/decapitalize.test.js b/test/decapitalize/decapitalize.test.js new file mode 100644 index 000000000..5ce0e6f5c --- /dev/null +++ b/test/decapitalize/decapitalize.test.js @@ -0,0 +1,13 @@ +const test = require('tape'); +const decapitalize = require('./decapitalize.js'); + +test('Testing decapitalize', (t) => { + //For more information on all the methods supported by tape + //Please go to https://github.com/substack/tape + t.true(typeof decapitalize === 'function', 'decapitalize is a Function'); + //t.deepEqual(decapitalize(args..), 'Expected'); + //t.equal(decapitalize(args..), 'Expected'); + //t.false(decapitalize(args..), 'Expected'); + //t.throws(decapitalize(args..), 'Expected'); + t.end(); +}); \ No newline at end of file diff --git a/test/flattenDepth/flattenDepth.js b/test/flattenDepth/flattenDepth.js new file mode 100644 index 000000000..9e4606a75 --- /dev/null +++ b/test/flattenDepth/flattenDepth.js @@ -0,0 +1,4 @@ +module.exports = flattenDepth = (arr, depth = 1) => +depth != 1 +? arr.reduce((a, v) => a.concat(Array.isArray(v) ? flattenDepth(v, depth - 1) : v), []) +: arr.reduce((a, v) => a.concat(v), []); \ No newline at end of file diff --git a/test/flattenDepth/flattenDepth.test.js b/test/flattenDepth/flattenDepth.test.js new file mode 100644 index 000000000..113fbce1e --- /dev/null +++ b/test/flattenDepth/flattenDepth.test.js @@ -0,0 +1,13 @@ +const test = require('tape'); +const flattenDepth = require('./flattenDepth.js'); + +test('Testing flattenDepth', (t) => { + //For more information on all the methods supported by tape + //Please go to https://github.com/substack/tape + t.true(typeof flattenDepth === 'function', 'flattenDepth is a Function'); + //t.deepEqual(flattenDepth(args..), 'Expected'); + //t.equal(flattenDepth(args..), 'Expected'); + //t.false(flattenDepth(args..), 'Expected'); + //t.throws(flattenDepth(args..), 'Expected'); + t.end(); +}); \ No newline at end of file diff --git a/test/isObject/isObject.js b/test/isObject/isObject.js new file mode 100644 index 000000000..98dbe499e --- /dev/null +++ b/test/isObject/isObject.js @@ -0,0 +1 @@ +module.exports = isObject = obj => obj === Object(obj); \ No newline at end of file diff --git a/test/isObject/isObject.test.js b/test/isObject/isObject.test.js new file mode 100644 index 000000000..9688b131a --- /dev/null +++ b/test/isObject/isObject.test.js @@ -0,0 +1,13 @@ +const test = require('tape'); +const isObject = require('./isObject.js'); + +test('Testing isObject', (t) => { + //For more information on all the methods supported by tape + //Please go to https://github.com/substack/tape + t.true(typeof isObject === 'function', 'isObject is a Function'); + //t.deepEqual(isObject(args..), 'Expected'); + //t.equal(isObject(args..), 'Expected'); + //t.false(isObject(args..), 'Expected'); + //t.throws(isObject(args..), 'Expected'); + t.end(); +}); \ No newline at end of file