From 2f35962a2b578ed3126ff84e0b741d67c115518e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Feje=C5=A1?= Date: Wed, 10 Jan 2018 08:27:23 +0100 Subject: [PATCH 01/10] add test for validateNumber --- package-lock.json | 6 ++++++ test/validateNumber/validateNumber.test.js | 1 + 2 files changed, 7 insertions(+) diff --git a/package-lock.json b/package-lock.json index 21f1a9c9c..551d294be 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1323,6 +1323,7 @@ "version": "1.7.1", "resolved": "https://registry.npmjs.org/clipboard/-/clipboard-1.7.1.tgz", "integrity": "sha1-Ng1taUbpmnof7zleQrqStem1oWs=", + "dev": true, "optional": true, "requires": { "good-listener": "1.2.2", @@ -1601,6 +1602,7 @@ "version": "3.2.0", "resolved": "https://registry.npmjs.org/delegate/-/delegate-3.2.0.tgz", "integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw==", + "dev": true, "optional": true }, "delegates": { @@ -2388,6 +2390,7 @@ "version": "1.2.2", "resolved": "https://registry.npmjs.org/good-listener/-/good-listener-1.2.2.tgz", "integrity": "sha1-1TswzfkxPf+33JoNR3CWqm0UXFA=", + "dev": true, "optional": true, "requires": { "delegate": "3.2.0" @@ -3700,6 +3703,7 @@ "version": "1.9.0", "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.9.0.tgz", "integrity": "sha1-+j4tntw8OIfB8fMJXUHx+bQgDw8=", + "dev": true, "requires": { "clipboard": "1.7.1" } @@ -4113,6 +4117,7 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/select/-/select-1.1.2.tgz", "integrity": "sha1-DnNQrN7ICxEIUoeG7B1EGNEbOW0=", + "dev": true, "optional": true }, "semistandard": { @@ -4570,6 +4575,7 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.0.2.tgz", "integrity": "sha512-2NM0auVBGft5tee/OxP4PI3d8WItkDM+fPnaRAVo6xTDI2knbz9eC5ArWGqtGlYqiH3RU5yMpdyTTO7MguC4ow==", + "dev": true, "optional": true }, "to-fast-properties": { diff --git a/test/validateNumber/validateNumber.test.js b/test/validateNumber/validateNumber.test.js index 921edec24..8a6d847ad 100644 --- a/test/validateNumber/validateNumber.test.js +++ b/test/validateNumber/validateNumber.test.js @@ -5,6 +5,7 @@ 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'); From 79929a3e552caf4ec72bcbc62904cbb2d8686852 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Feje=C5=A1?= Date: Wed, 10 Jan 2018 08:28:58 +0100 Subject: [PATCH 02/10] add test for isDivisible --- test/isDivisible/isDivisible.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/isDivisible/isDivisible.test.js b/test/isDivisible/isDivisible.test.js index be73cdba5..40eeb4bc9 100644 --- a/test/isDivisible/isDivisible.test.js +++ b/test/isDivisible/isDivisible.test.js @@ -5,8 +5,8 @@ test('Testing isDivisible', (t) => { //For more information on all the methods supported by tape //Please go to https://github.com/substack/tape t.true(typeof isDivisible === 'function', 'isDivisible is a Function'); + t.equal(isDivisible(6, 3), true, 'The number 6 is divisible by 3'); //t.deepEqual(isDivisible(args..), 'Expected'); - //t.equal(isDivisible(args..), 'Expected'); //t.false(isDivisible(args..), 'Expected'); //t.throws(isDivisible(args..), 'Expected'); t.end(); From 3df3027cb08a7cc21c3c13fb8b451b92a61e2f15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Feje=C5=A1?= Date: Wed, 10 Jan 2018 08:30:53 +0100 Subject: [PATCH 03/10] add test for isEven --- test/isEven/isEven.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/isEven/isEven.test.js b/test/isEven/isEven.test.js index d6a540d56..6436226b4 100644 --- a/test/isEven/isEven.test.js +++ b/test/isEven/isEven.test.js @@ -5,9 +5,9 @@ test('Testing isEven', (t) => { //For more information on all the methods supported by tape //Please go to https://github.com/substack/tape t.true(typeof isEven === 'function', 'isEven is a Function'); + t.equal(isEven(4), true, '4 is even number'); + t.false(isEven(5), false, '5 is not an even number'); //t.deepEqual(isEven(args..), 'Expected'); - //t.equal(isEven(args..), 'Expected'); - //t.false(isEven(args..), 'Expected'); //t.throws(isEven(args..), 'Expected'); t.end(); }); \ No newline at end of file From f1df2679e52e8c1d1f96b11c6d62b29bd8779acb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Feje=C5=A1?= Date: Wed, 10 Jan 2018 10:37:20 +0100 Subject: [PATCH 04/10] add test for isSorted --- test/isSorted/isSorted.test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/isSorted/isSorted.test.js b/test/isSorted/isSorted.test.js index b41aef9ef..bdc272dcb 100644 --- a/test/isSorted/isSorted.test.js +++ b/test/isSorted/isSorted.test.js @@ -6,7 +6,8 @@ test('Testing isSorted', (t) => { //Please go to https://github.com/substack/tape t.true(typeof isSorted === 'function', 'isSorted is a Function'); //t.deepEqual(isSorted(args..), 'Expected'); - //t.equal(isSorted(args..), 'Expected'); + t.equal(isSorted([0, 1, 2, 2]), 1, 'Array is sorted in ascending order'); + t.equal(isSorted([4, 3, 2]), -1, 'Array is sorted in descending order'); //t.false(isSorted(args..), 'Expected'); //t.throws(isSorted(args..), 'Expected'); t.end(); From c6fd57743b66b4edc4fee33b05504e78b8d2b33f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Feje=C5=A1?= Date: Wed, 10 Jan 2018 10:57:52 +0100 Subject: [PATCH 05/10] add test isString, update isSorted --- test/isSorted/isSorted.test.js | 1 + test/isString/isString.test.js | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/test/isSorted/isSorted.test.js b/test/isSorted/isSorted.test.js index bdc272dcb..183435cd4 100644 --- a/test/isSorted/isSorted.test.js +++ b/test/isSorted/isSorted.test.js @@ -8,6 +8,7 @@ test('Testing isSorted', (t) => { //t.deepEqual(isSorted(args..), 'Expected'); t.equal(isSorted([0, 1, 2, 2]), 1, 'Array is sorted in ascending order'); t.equal(isSorted([4, 3, 2]), -1, 'Array is sorted in descending order'); + t.equal(isSorted([4, 3, 5]), 0, 'Array is not sorted, direction changed in array') //t.false(isSorted(args..), 'Expected'); //t.throws(isSorted(args..), 'Expected'); t.end(); diff --git a/test/isString/isString.test.js b/test/isString/isString.test.js index c3b892e27..7d47db410 100644 --- a/test/isString/isString.test.js +++ b/test/isString/isString.test.js @@ -5,6 +5,12 @@ test('Testing isString', (t) => { //For more information on all the methods supported by tape //Please go to https://github.com/substack/tape t.true(typeof isString === 'function', 'isString is a Function'); + t.equal(isString('foo'), true, 'foo is a string'); + t.equal(isString('10'), true, '"10" is a string'); + t.equal(isString(''), true, 'Empty string is a string'); + t.equal(isString(10), false, '10 is not a string'); + t.equal(isString(true), false, 'true is not string'); + //t.deepEqual(isString(args..), 'Expected'); //t.equal(isString(args..), 'Expected'); //t.false(isString(args..), 'Expected'); From 35a4f17536d8264c6d8cd8d867f347b79dae59c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Feje=C5=A1?= Date: Wed, 10 Jan 2018 11:05:56 +0100 Subject: [PATCH 06/10] add 2 tests, isUpperCase and isValidJSON --- test/isUpperCase/isUpperCase.test.js | 4 +++- test/isValidJSON/isValidJSON.test.js | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/test/isUpperCase/isUpperCase.test.js b/test/isUpperCase/isUpperCase.test.js index 9bc274be5..e42088f8e 100644 --- a/test/isUpperCase/isUpperCase.test.js +++ b/test/isUpperCase/isUpperCase.test.js @@ -6,7 +6,9 @@ test('Testing isUpperCase', (t) => { //Please go to https://github.com/substack/tape t.true(typeof isUpperCase === 'function', 'isUpperCase is a Function'); //t.deepEqual(isUpperCase(args..), 'Expected'); - //t.equal(isUpperCase(args..), 'Expected'); + t.equal(isUpperCase('ABC'), true, 'ABC is all upper case'); + t.equal(isUpperCase('abc'), false, 'abc is not all upper case'); + t.equal(isUpperCase('A3@$'), true, 'A3@$ is all uppercase'); //t.false(isUpperCase(args..), 'Expected'); //t.throws(isUpperCase(args..), 'Expected'); t.end(); diff --git a/test/isValidJSON/isValidJSON.test.js b/test/isValidJSON/isValidJSON.test.js index 31bb543a6..1c38c04d0 100644 --- a/test/isValidJSON/isValidJSON.test.js +++ b/test/isValidJSON/isValidJSON.test.js @@ -5,6 +5,9 @@ test('Testing isValidJSON', (t) => { //For more information on all the methods supported by tape //Please go to https://github.com/substack/tape t.true(typeof isValidJSON === 'function', 'isValidJSON is a Function'); + t.equal(isValidJSON('{"name":"Adam","age":20}'), true, '{"name":"Adam","age":20} is a valid JSON'); + t.equal(isValidJSON('{"name":"Adam",age:"20"}'), false, '{"name":"Adam",age:"20"} is not a valid JSON'); + t.equal(isValidJSON(null), true, 'null is a valid JSON'); //t.deepEqual(isValidJSON(args..), 'Expected'); //t.equal(isValidJSON(args..), 'Expected'); //t.false(isValidJSON(args..), 'Expected'); From 5c24a029583a24a154df0707fb4c0f0ffcb35e69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Feje=C5=A1?= Date: Wed, 10 Jan 2018 11:13:32 +0100 Subject: [PATCH 07/10] add test for truncateString --- test/truncateString/truncateString.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/truncateString/truncateString.test.js b/test/truncateString/truncateString.test.js index 0b6ef0997..da3ce1d3c 100644 --- a/test/truncateString/truncateString.test.js +++ b/test/truncateString/truncateString.test.js @@ -5,7 +5,7 @@ test('Testing truncateString', (t) => { //For more information on all the methods supported by tape //Please go to https://github.com/substack/tape t.true(typeof truncateString === 'function', 'truncateString is a Function'); - //t.deepEqual(truncateString(args..), 'Expected'); + t.equal(truncateString('boomerang', 7), 'boom...', 'Truncates a "boomerang" up to a specified length.'); //t.equal(truncateString(args..), 'Expected'); //t.false(truncateString(args..), 'Expected'); //t.throws(truncateString(args..), 'Expected'); From 02d59949c3382eea73859bd0cbfeefa06c4e91e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Feje=C5=A1?= Date: Wed, 10 Jan 2018 11:24:21 +0100 Subject: [PATCH 08/10] add 2 tests, yesNo and unescapeHTML There is a bug with words.test (I've commented on it) --- test/unescapeHTML/unescapeHTML.test.js | 1 + test/words/words.test.js | 1 + test/yesNo/yesNo.test.js | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/test/unescapeHTML/unescapeHTML.test.js b/test/unescapeHTML/unescapeHTML.test.js index 3014e5820..5bd5d9eb9 100644 --- a/test/unescapeHTML/unescapeHTML.test.js +++ b/test/unescapeHTML/unescapeHTML.test.js @@ -5,6 +5,7 @@ test('Testing unescapeHTML', (t) => { //For more information on all the methods supported by tape //Please go to https://github.com/substack/tape t.true(typeof unescapeHTML === 'function', 'unescapeHTML is a Function'); + t.equal(unescapeHTML('<a href="#">Me & you</a>'), 'Me & you', 'Unescapes escaped HTML characters.'); //t.deepEqual(unescapeHTML(args..), 'Expected'); //t.equal(unescapeHTML(args..), 'Expected'); //t.false(unescapeHTML(args..), 'Expected'); diff --git a/test/words/words.test.js b/test/words/words.test.js index c8deb7c41..b64edd235 100644 --- a/test/words/words.test.js +++ b/test/words/words.test.js @@ -5,6 +5,7 @@ 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.equal(words('I love javaScript!!'), ["I", "love", "javaScript"], "Returns words from a string"); //t.deepEqual(words(args..), 'Expected'); //t.equal(words(args..), 'Expected'); //t.false(words(args..), 'Expected'); diff --git a/test/yesNo/yesNo.test.js b/test/yesNo/yesNo.test.js index 2d49b71a6..20922855a 100644 --- a/test/yesNo/yesNo.test.js +++ b/test/yesNo/yesNo.test.js @@ -5,6 +5,11 @@ 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.deepEqual(yesNo(args..), 'Expected'); //t.equal(yesNo(args..), 'Expected'); //t.false(yesNo(args..), 'Expected'); From bc40529a73b1f29bf3ab16ff7ad656ea0aea6155 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Feje=C5=A1?= Date: Wed, 10 Jan 2018 11:34:15 +0100 Subject: [PATCH 09/10] add 2 tests, toOrdinalSuffix, toSafeInteger --- test/toOrdinalSuffix/toOrdinalSuffix.test.js | 5 +++++ test/toSafeInteger/toSafeInteger.test.js | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/test/toOrdinalSuffix/toOrdinalSuffix.test.js b/test/toOrdinalSuffix/toOrdinalSuffix.test.js index bc261a66c..d33dead0a 100644 --- a/test/toOrdinalSuffix/toOrdinalSuffix.test.js +++ b/test/toOrdinalSuffix/toOrdinalSuffix.test.js @@ -5,6 +5,11 @@ test('Testing toOrdinalSuffix', (t) => { //For more information on all the methods supported by tape //Please go to https://github.com/substack/tape t.true(typeof toOrdinalSuffix === 'function', 'toOrdinalSuffix is a Function'); + t.equal(toOrdinalSuffix('123'), '123rd', 'Adds an ordinal suffix to a number'); + t.equal(toOrdinalSuffix(5), '5th', 'Adds an ordinal suffix to a number'); + t.equal(toOrdinalSuffix(1), '1st', 'Adds an ordinal suffix to a number'); + t.equal(toOrdinalSuffix(0), '0th', 'Adds an ordinal suffix to a number'); + // t.equal(toOrdinalSuffix(), ,); //t.deepEqual(toOrdinalSuffix(args..), 'Expected'); //t.equal(toOrdinalSuffix(args..), 'Expected'); //t.false(toOrdinalSuffix(args..), 'Expected'); diff --git a/test/toSafeInteger/toSafeInteger.test.js b/test/toSafeInteger/toSafeInteger.test.js index d60c7a9d9..e04013774 100644 --- a/test/toSafeInteger/toSafeInteger.test.js +++ b/test/toSafeInteger/toSafeInteger.test.js @@ -5,6 +5,11 @@ test('Testing toSafeInteger', (t) => { //For more information on all the methods supported by tape //Please go to https://github.com/substack/tape t.true(typeof toSafeInteger === 'function', 'toSafeInteger is a Function'); + t.equal(toSafeInteger(3.2), 3, "Converts a value to a safe integer"); + t.equal(toSafeInteger('4.2'), 4, "Converts a value to a safe integer"); + t.equal(toSafeInteger(4.6), 5, "Converts a value to a safe integer"); + t.equal(toSafeInteger(1.5), 2, "Converts a value to a safe integer"); + t.equal(toSafeInteger(Infinity), 9007199254740991, "Converts a value to a safe integer"); //t.deepEqual(toSafeInteger(args..), 'Expected'); //t.equal(toSafeInteger(args..), 'Expected'); //t.false(toSafeInteger(args..), 'Expected'); From 4c7f279dd1411c5398fd76a56dff46b13bd5b9a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Feje=C5=A1?= Date: Wed, 10 Jan 2018 11:47:47 +0100 Subject: [PATCH 10/10] update words test, My bad I didn't use deepEqual when comparing ... --- test/words/words.test.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/words/words.test.js b/test/words/words.test.js index b64edd235..f15d1446f 100644 --- a/test/words/words.test.js +++ b/test/words/words.test.js @@ -5,7 +5,9 @@ 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.equal(words('I love javaScript!!'), ["I", "love", "javaScript"], "Returns words from a string"); + 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(args..), 'Expected'); //t.equal(words(args..), 'Expected'); //t.false(words(args..), 'Expected');