diff --git a/test/validateNumber/validateNumber.test.js b/test/validateNumber/validateNumber.test.js index 8a6d847ad..4f8908d88 100644 --- a/test/validateNumber/validateNumber.test.js +++ b/test/validateNumber/validateNumber.test.js @@ -5,10 +5,18 @@ test('Testing validateNumber', (t) => { //For more information on all the methods supported by tape //Please go to https://github.com/substack/tape t.true(typeof validateNumber === 'function', 'validateNumber is a Function'); - t.equal(validateNumber(9), true, '9 is a number'); - //t.deepEqual(validateNumber(args..), 'Expected'); - //t.equal(validateNumber(args..), 'Expected'); - //t.false(validateNumber(args..), 'Expected'); - //t.throws(validateNumber(args..), 'Expected'); + t.true(validateNumber(9), 'validateNumber(9) returns true'); + t.true(validateNumber('234asd'.slice(0, 2)), 'validateNumber(234asd.slice(0, 2)) returns true'); + t.true(validateNumber(1232), 'validateNumber(1232) returns true'); + t.true(validateNumber(1232 + 13423), 'validateNumber(1232 + 13423) returns true'); + t.true(validateNumber(1232 * 2342 * 123), 'validateNumber(1232 * 2342 * 123) returns true'); + t.true(validateNumber(1232.23423536), 'validateNumber(1232.23423536) returns true'); + t.false(validateNumber('234asd'), 'validateNumber(234asd) returns false'); + t.false(validateNumber('e234d'), 'validateNumber(e234d) returns false'); + t.false(validateNumber(false), 'validateNumber(false) returns false'); + t.false(validateNumber(true), 'validateNumber(true) returns false'); + t.false(validateNumber(null), 'validateNumber(null) returns false'); + t.false(validateNumber(123 * 'asd'), 'validateNumber(123 * asd) returns false'); + t.end(); -}); \ No newline at end of file +}); diff --git a/test/without/without.test.js b/test/without/without.test.js index f731a0714..09fdcb121 100644 --- a/test/without/without.test.js +++ b/test/without/without.test.js @@ -5,10 +5,15 @@ test('Testing without', (t) => { //For more information on all the methods supported by tape //Please go to https://github.com/substack/tape t.true(typeof without === 'function', 'without is a Function'); - t.deepEqual(without([2, 1, 2, 3], 1, 2), [3], "Filters out the elements of an array, that have one of the specified values."); - //t.deepEqual(without(args..), 'Expected'); - //t.equal(without(args..), 'Expected'); - //t.false(without(args..), 'Expected'); - //t.throws(without(args..), 'Expected'); + t.deepEqual(without([2, 1, 2, 3], 1, 2), [3], "without([2, 1, 2, 3], 1, 2) returns [3]"); + t.deepEqual(without([]), [], "without([]) returns []"); + t.deepEqual(without([3, 1, true, '3', true], '3', true), [3, 1], "without([3, 1, true, '3', true], '3', true) returns [3, 1]"); + t.deepEqual(without('string'.split(''), 's', 't', 'g'), ['r', 'i', 'n'], "without('string'.split(''), 's', 't', 'g') returns ['r', 'i', 'n']"); + t.throws(() => without(), 'without() throws an error'); + t.throws(() => without(null), 'without(null) throws an error'); + t.throws(() => without(undefined), 'without(undefined) throws an error'); + t.throws(() => without(123), 'without() throws an error'); + t.throws(() => without({}), 'without({}) throws an error'); + t.end(); -}); \ No newline at end of file +}); diff --git a/test/words/words.test.js b/test/words/words.test.js index f15d1446f..bb92b2c10 100644 --- a/test/words/words.test.js +++ b/test/words/words.test.js @@ -5,12 +5,15 @@ test('Testing words', (t) => { //For more information on all the methods supported by tape //Please go to https://github.com/substack/tape t.true(typeof words === 'function', 'words is a Function'); - t.deepEqual(words('I love javaScript!!'), ["I", "love", "javaScript"], "Returns words from a string"); - t.deepEqual(words('python, javaScript & coffee'), ["python", "javaScript", "coffee"], "Returns words from a string"); + t.deepEqual(words('I love javaScript!!'), ["I", "love", "javaScript"], "words('I love javaScript!!') returns [I, love, javaScript]"); + t.deepEqual(words('python, javaScript & coffee'), ["python", "javaScript", "coffee"], "words('python, javaScript & coffee') returns [python, javaScript, coffee]"); + t.true(Array.isArray(words('I love javaScript!!')), 'words(I love javaScript!!) returns an array'); + t.throws(() => words(), 'words() throws a error'); + t.throws(() => words(null), 'words(null) throws a error'); + t.throws(() => words(undefined), 'words(undefined) throws a error'); + t.throws(() => words({}), 'words({}) throws a error'); + t.throws(() => words([]), 'words([]) throws a error'); + t.throws(() => words(1234), 'words(1234) throws a error'); - //t.deepEqual(words(args..), 'Expected'); - //t.equal(words(args..), 'Expected'); - //t.false(words(args..), 'Expected'); - //t.throws(words(args..), 'Expected'); t.end(); -}); \ No newline at end of file +}); diff --git a/test/yesNo/yesNo.test.js b/test/yesNo/yesNo.test.js index 20922855a..c50e452db 100644 --- a/test/yesNo/yesNo.test.js +++ b/test/yesNo/yesNo.test.js @@ -5,14 +5,18 @@ test('Testing yesNo', (t) => { //For more information on all the methods supported by tape //Please go to https://github.com/substack/tape t.true(typeof yesNo === 'function', 'yesNo is a Function'); - t.equal(yesNo('Y'), true, 'Returns true as the provided string is y/yes'); - t.equal(yesNo('yes'), true, 'Returns true as the provided string is y/yes'); - t.equal(yesNo('No'), false, 'Returns false as the provided string is n/no'); - t.equal(yesNo('foo', true), true, 'Returns true since the 2nd argument is ommited'); + t.true(yesNo('Y'), 'yesNo(Y) returns true'); + t.true(yesNo('yes'), 'yesNo(yes) returns true'); + t.true(yesNo('foo', true), 'yesNo(foo, true) returns true'); + t.false(yesNo('No'), 'yesNo(No) returns false'); + t.false(yesNo(), 'yesNo() returns false'); + t.false(yesNo(null), 'yesNo(null) returns false'); + t.false(yesNo(undefined), 'yesNo(undefined) returns false'); + t.false(yesNo([123, null]), 'yesNo([123, null]) returns false'); + t.false(yesNo(['Yes', 'No']), 'yesNo([Yes, No]) returns false'); + t.false(yesNo({ 2: 'Yes' }), 'yesNo({ 2: Yes }) returns false'); + t.true(yesNo(['Yes', 'No'], true), 'yesNo([Yes, No], true) returns true'); + t.true(yesNo({ 2: 'Yes' }, true), 'yesNo({ 2: Yes }, true) returns true'); - //t.deepEqual(yesNo(args..), 'Expected'); - //t.equal(yesNo(args..), 'Expected'); - //t.false(yesNo(args..), 'Expected'); - //t.throws(yesNo(args..), 'Expected'); t.end(); -}); \ No newline at end of file +}); diff --git a/test/zip/zip.test.js b/test/zip/zip.test.js index f222d90a5..c198670d9 100644 --- a/test/zip/zip.test.js +++ b/test/zip/zip.test.js @@ -5,11 +5,14 @@ test('Testing zip', (t) => { //For more information on all the methods supported by tape //Please go to https://github.com/substack/tape t.true(typeof zip === 'function', 'zip is a Function'); - t.deepEqual(zip(['a', 'b'], [1, 2], [true, false]), [['a', 1, true], ['b', 2, false]], 'Object was zipped'); - t.deepEqual(zip(['a'], [1, 2], [true, false]), [['a', 1, true], [undefined, 2, false]], 'Object was zipped'); - t.true(Array.isArray(zip(['a', 'b'], [1, 2], [true, false])), 'zip returns an Array'); - t.true(Array.isArray(zip(['a'], [1, 2], [true, false])), 'zip returns an Array'); - //t.false(zip(args..), 'Expected'); - //t.throws(zip(args..), 'Expected'); + t.deepEqual(zip(['a', 'b'], [1, 2], [true, false]), [['a', 1, true], ['b', 2, false]], 'zip([a, b], [1, 2], [true, false]) returns [[a, 1, true], [b, 2, false]]'); + t.deepEqual(zip(['a'], [1, 2], [true, false]), [['a', 1, true], [undefined, 2, false]], 'zip([a], [1, 2], [true, false]) returns [[a, 1, true], [undefined, 2, false]]'); + t.deepEqual(zip(), [], 'zip([]) returns []'); + t.deepEqual(zip(123), [], 'zip(123) returns []'); + t.true(Array.isArray(zip(['a', 'b'], [1, 2], [true, false])), 'zip([a, b], [1, 2], [true, false]) returns an Array'); + t.true(Array.isArray(zip(['a'], [1, 2], [true, false])), 'zip([a], [1, 2], [true, false]) returns an Array'); + t.throws(() => zip(null), 'zip(null) throws an error'); + t.throws(() => zip(undefined), 'zip(undefined) throws an error'); + t.end(); }); diff --git a/test/zipObject/zipObject.test.js b/test/zipObject/zipObject.test.js index fb17581eb..ab0f9223d 100644 --- a/test/zipObject/zipObject.test.js +++ b/test/zipObject/zipObject.test.js @@ -5,10 +5,15 @@ test('Testing zipObject', (t) => { //For more information on all the methods supported by tape //Please go to https://github.com/substack/tape t.true(typeof zipObject === 'function', 'zipObject is a Function'); - t.deepEqual(zipObject(['a', 'b', 'c'], [1, 2]), {a: 1, b: 2, c: undefined}, 'Array was zipped to object'); - t.deepEqual(zipObject(['a', 'b'], [1, 2, 3]), {a: 1, b: 2}, 'Array was zipped to object'); - //t.equal(zipObject(args..), 'Expected'); - //t.false(zipObject(args..), 'Expected'); - //t.throws(zipObject(args..), 'Expected'); + t.deepEqual(zipObject(['a', 'b', 'c'], [1, 2]), {a: 1, b: 2, c: undefined}, 'zipObject([a, b, c], [1, 2]) returns {a: 1, b: 2, c: undefined}'); + t.deepEqual(zipObject(['a', 'b'], [1, 2, 3]), {a: 1, b: 2}, 'zipObject([a, b], [1, 2, 3]) returns {a: 1, b: 2}'); + t.deepEqual(zipObject(['a', 'b', 'c'], 'string'), { a: 's', b: 't', c: 'r' }, 'zipObject([a, b, c], string) returns { a: s, b: t, c: r }'); + t.deepEqual(zipObject(['a'], 'string'), { a: 's' }, 'zipObject([a], string) returns { a: s }'); + t.throws(() => zipObject(), 'zipObject() throws an error'); + t.throws(() => zipObject(['string'], null), 'zipObject([string], null) throws an error'); + t.throws(() => zipObject(null, [1]), 'zipObject(null, [1]) throws an error'); + t.throws(() => zipObject('string'), 'zipObject(string) throws an error'); + t.throws(() => zipObject('test', 'string'), 'zipObject(test, string) throws an error'); + t.end(); });