Merge pull request #527 from Chalarangelo/snippet-tests

Snippet tests 2nd edition
This commit is contained in:
Angelos Chalaris
2018-01-10 21:05:51 +02:00
committed by GitHub
56 changed files with 95 additions and 4 deletions

View File

@ -5,6 +5,8 @@ test('Testing anagrams', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof anagrams === 'function', 'anagrams is a Function');
//BROKEN
// t.deepEqual(anagrams('abc'), ['abc','acb','bac','bca','cab','cba'], "Generates all anagrams of a string");
//t.deepEqual(anagrams(args..), 'Expected');
//t.equal(anagrams(args..), 'Expected');
//t.false(anagrams(args..), 'Expected');

View File

@ -5,6 +5,8 @@ test('Testing byteSize', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof byteSize === 'function', 'byteSize is a Function');
// Works only in browser
// t.equal(byteSize('Hello World'), 11, "Returns the length of a string in bytes");
//t.deepEqual(byteSize(args..), 'Expected');
//t.equal(byteSize(args..), 'Expected');
//t.false(byteSize(args..), 'Expected');

View File

@ -5,6 +5,8 @@ test('Testing capitalize', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof capitalize === 'function', 'capitalize is a Function');
t.equal(capitalize('fooBar'), 'FooBar', "Capitalizes the first letter of a string");
t.equal(capitalize('fooBar', true), 'Foobar', "Capitalizes the first letter of a string");
//t.deepEqual(capitalize(args..), 'Expected');
//t.equal(capitalize(args..), 'Expected');
//t.false(capitalize(args..), 'Expected');

View File

@ -5,6 +5,7 @@ test('Testing capitalizeEveryWord', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof capitalizeEveryWord === 'function', 'capitalizeEveryWord is a Function');
t.equal(capitalizeEveryWord('hello world!'), 'Hello World!', "Capitalizes the first letter of every word in a string");
//t.deepEqual(capitalizeEveryWord(args..), 'Expected');
//t.equal(capitalizeEveryWord(args..), 'Expected');
//t.false(capitalizeEveryWord(args..), 'Expected');

View File

@ -5,6 +5,7 @@ test('Testing chunk', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof chunk === 'function', 'chunk is a Function');
t.deepEqual(chunk([1, 2, 3, 4, 5], 2), [[1,2],[3,4],[5]], "Chunks an array into smaller arrays of a specified size");
//t.deepEqual(chunk(args..), 'Expected');
//t.equal(chunk(args..), 'Expected');
//t.false(chunk(args..), 'Expected');

View File

@ -5,6 +5,7 @@ test('Testing clampNumber', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof clampNumber === 'function', 'clampNumber is a Function');
t.equal(clampNumber(2, 3, 5), 3, "Clamps num within the inclusive range specified by the boundary values a and b");
//t.deepEqual(clampNumber(args..), 'Expected');
//t.equal(clampNumber(args..), 'Expected');
//t.false(clampNumber(args..), 'Expected');

View File

@ -5,6 +5,7 @@ test('Testing coalesce', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof coalesce === 'function', 'coalesce is a Function');
t.deepEqual(coalesce(null, undefined, '', NaN, 'Waldo'), '', "Returns the first non-null/undefined argument");
//t.deepEqual(coalesce(args..), 'Expected');
//t.equal(coalesce(args..), 'Expected');
//t.false(coalesce(args..), 'Expected');

View File

@ -5,6 +5,8 @@ test('Testing coalesceFactory', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof coalesceFactory === 'function', 'coalesceFactory is a Function');
const customCoalesce = coalesceFactory(_ => ![null, undefined, '', NaN].includes(_));
t.deepEqual(customCoalesce(undefined, null, NaN, '', 'Waldo'), 'Waldo', "Returns a customized coalesce function");
//t.deepEqual(coalesceFactory(args..), 'Expected');
//t.equal(coalesceFactory(args..), 'Expected');
//t.false(coalesceFactory(args..), 'Expected');

View File

@ -5,6 +5,7 @@ test('Testing compact', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof compact === 'function', 'compact is a Function');
t.deepEqual(compact([0, 1, false, 2, '', 3, 'a', 'e' * 23, NaN, 's', 34]), [ 1, 2, 3, 'a', 's', 34 ], "Removes falsey values from an array");
//t.deepEqual(compact(args..), 'Expected');
//t.equal(compact(args..), 'Expected');
//t.false(compact(args..), 'Expected');

View File

@ -5,6 +5,10 @@ test('Testing compose', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof compose === 'function', 'compose is a Function');
const add5 = x => x + 5;
const multiply = (x, y) => x * y;
const multiplyAndAdd5 = compose(add5, multiply);
t.equal(multiplyAndAdd5(5, 2), 15, "Performs right-to-left function composition");
//t.deepEqual(compose(args..), 'Expected');
//t.equal(compose(args..), 'Expected');
//t.false(compose(args..), 'Expected');

View File

@ -5,6 +5,7 @@ test('Testing countOccurrences', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof countOccurrences === 'function', 'countOccurrences is a Function');
t.deepEqual(countOccurrences([1, 1, 2, 1, 2, 3], 1), 3, "Counts the occurrences of a value in an array");
//t.deepEqual(countOccurrences(args..), 'Expected');
//t.equal(countOccurrences(args..), 'Expected');
//t.false(countOccurrences(args..), 'Expected');

View File

@ -5,6 +5,8 @@ test('Testing curry', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof curry === 'function', 'curry is a Function');
//BROKEN
// t.equal(curry(Math.pow)(2)(10), 1024, "Curries a function");
//t.deepEqual(curry(args..), 'Expected');
//t.equal(curry(args..), 'Expected');
//t.false(curry(args..), 'Expected');

View File

@ -5,6 +5,8 @@ test('Testing deepFlatten', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof deepFlatten === 'function', 'deepFlatten is a Function');
//BROKEN
// t.deepEqual(deepFlatten([1, [2], [[3], 4], 5]), [1, 2, 3, 4, 5], "Deep flattens an array");
//t.deepEqual(deepFlatten(args..), 'Expected');
//t.equal(deepFlatten(args..), 'Expected');
//t.false(deepFlatten(args..), 'Expected');

View File

@ -5,6 +5,7 @@ test('Testing difference', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof difference === 'function', 'difference is a Function');
t.deepEqual(difference([1, 2, 3], [1, 2, 4]), [3], "Returns the difference between two arrays");
//t.deepEqual(difference(args..), 'Expected');
//t.equal(difference(args..), 'Expected');
//t.false(difference(args..), 'Expected');

View File

@ -5,6 +5,7 @@ test('Testing differenceWith', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof differenceWith === 'function', 'differenceWith is a Function');
t.deepEqual(differenceWith([1, 1.2, 1.5, 3, 0], [1.9, 3, 0], (a, b) => Math.round(a) === Math.round(b)), [1, 1.2], "Filters out all values from an array");
//t.deepEqual(differenceWith(args..), 'Expected');
//t.equal(differenceWith(args..), 'Expected');
//t.false(differenceWith(args..), 'Expected');

View File

@ -5,6 +5,7 @@ test('Testing digitize', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof digitize === 'function', 'digitize is a Function');
t.deepEqual(digitize(123), [1, 2, 3], "Converts a number to an array of digits");
//t.deepEqual(digitize(args..), 'Expected');
//t.equal(digitize(args..), 'Expected');
//t.false(digitize(args..), 'Expected');

View File

@ -5,6 +5,7 @@ test('Testing distinctValuesOfArray', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof distinctValuesOfArray === 'function', 'distinctValuesOfArray is a Function');
t.deepEqual(distinctValuesOfArray([1, 2, 2, 3, 4, 4, 5]), [1,2,3,4,5], "Returns all the distinct values of an array");
//t.deepEqual(distinctValuesOfArray(args..), 'Expected');
//t.equal(distinctValuesOfArray(args..), 'Expected');
//t.false(distinctValuesOfArray(args..), 'Expected');

View File

@ -5,6 +5,7 @@ test('Testing dropElements', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof dropElements === 'function', 'dropElements is a Function');
t.deepEqual(dropElements([1, 2, 3, 4], n => n >= 3), [3,4], "Removes elements in an array until the passed function returns true");
//t.deepEqual(dropElements(args..), 'Expected');
//t.equal(dropElements(args..), 'Expected');
//t.false(dropElements(args..), 'Expected');

View File

@ -5,6 +5,9 @@ test('Testing dropRight', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof dropRight === 'function', 'dropRight is a Function');
t.deepEqual(dropRight([1, 2, 3]), [1,2], "Returns a new array with n elements removed from the right");
t.deepEqual(dropRight([1, 2, 3], 2), [1], "Returns a new array with n elements removed from the right");
t.deepEqual(dropRight([1, 2, 3], 42), [], "Returns a new array with n elements removed from the right");
//t.deepEqual(dropRight(args..), 'Expected');
//t.equal(dropRight(args..), 'Expected');
//t.false(dropRight(args..), 'Expected');

View File

@ -4,7 +4,11 @@ const elo = require('./elo.js');
test('Testing elo', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof elo === 'function', 'elo is a Function');
// BORKEN
// t.true(typeof elo === 'function', 'elo is a Function');
// t.deepEqual(elo([1200, 1200]), [1216, 1184], "Standard 1v1s");
// t.deepEqual(elo([1200, 1200], 64), [1232, 1168]), "Standard 1v1s";
// t.deepEqual(elo([1200, 1200, 1200, 1200]).map(Math.round), [1246, 1215, 1185, 1154], "4 player FFA, all same rank");
//t.deepEqual(elo(args..), 'Expected');
//t.equal(elo(args..), 'Expected');
//t.false(elo(args..), 'Expected');

View File

@ -5,6 +5,7 @@ test('Testing escapeHTML', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof escapeHTML === 'function', 'escapeHTML is a Function');
t.equal(escapeHTML('<a href="#">Me & you</a>'), '&lt;a href=&quot;#&quot;&gt;Me &amp; you&lt;/a&gt;', "Escapes a string for use in HTML");
//t.deepEqual(escapeHTML(args..), 'Expected');
//t.equal(escapeHTML(args..), 'Expected');
//t.false(escapeHTML(args..), 'Expected');

View File

@ -5,6 +5,7 @@ test('Testing escapeRegExp', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof escapeRegExp === 'function', 'escapeRegExp is a Function');
t.equal(escapeRegExp('(test)'), '\\(test\\)', "Escapes a string to use in a regular expression");
//t.deepEqual(escapeRegExp(args..), 'Expected');
//t.equal(escapeRegExp(args..), 'Expected');
//t.false(escapeRegExp(args..), 'Expected');

View File

@ -5,6 +5,7 @@ test('Testing everyNth', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof everyNth === 'function', 'everyNth is a Function');
t.deepEqual(everyNth([1, 2, 3, 4, 5, 6], 2), [ 2, 4, 6 ], "Returns every nth element in an array");
//t.deepEqual(everyNth(args..), 'Expected');
//t.equal(everyNth(args..), 'Expected');
//t.false(everyNth(args..), 'Expected');

View File

@ -5,6 +5,8 @@ test('Testing extendHex', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof extendHex === 'function', 'extendHex is a Function');
t.equal(extendHex('#03f'), '#0033ff', "Extends a 3-digit color code to a 6-digit color code");
t.equal(extendHex('05a'), '#0055aa', "Extends a 3-digit color code to a 6-digit color code");
//t.deepEqual(extendHex(args..), 'Expected');
//t.equal(extendHex(args..), 'Expected');
//t.false(extendHex(args..), 'Expected');

View File

@ -5,6 +5,7 @@ test('Testing factorial', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof factorial === 'function', 'factorial is a Function');
// t.equal(factorial(6), 720, "Calculates the factorial of a number"); DOESN'T WORK
//t.deepEqual(factorial(args..), 'Expected');
//t.equal(factorial(args..), 'Expected');
//t.false(factorial(args..), 'Expected');

View File

@ -5,6 +5,7 @@ test('Testing fibonacci', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof fibonacci === 'function', 'fibonacci is a Function');
t.deepEqual(fibonacci(6), [0, 1, 1, 2, 3, 5], "Generates an array, containing the Fibonacci sequence");
//t.deepEqual(fibonacci(args..), 'Expected');
//t.equal(fibonacci(args..), 'Expected');
//t.false(fibonacci(args..), 'Expected');

View File

@ -5,6 +5,7 @@ test('Testing filterNonUnique', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof filterNonUnique === 'function', 'filterNonUnique is a Function');
t.deepEqual(filterNonUnique([1, 2, 2, 3, 4, 4, 5]), [1,3,5], "Filters out the non-unique values in an array");
//t.deepEqual(filterNonUnique(args..), 'Expected');
//t.equal(filterNonUnique(args..), 'Expected');
//t.false(filterNonUnique(args..), 'Expected');

View File

@ -5,6 +5,7 @@ test('Testing flatten', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof flatten === 'function', 'flatten is a Function');
t.deepEqual(flatten([1, [2], 3, 4]), [1, 2, 3, 4], "Flattens an array");
//t.deepEqual(flatten(args..), 'Expected');
//t.equal(flatten(args..), 'Expected');
//t.false(flatten(args..), 'Expected');

View File

@ -5,6 +5,7 @@ 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([1, [2], 3, 4]), [1, 2, 3, 4], "Flattens an array up to the specified depth");
//t.deepEqual(flattenDepth(args..), 'Expected');
//t.equal(flattenDepth(args..), 'Expected');
//t.false(flattenDepth(args..), 'Expected');

View File

@ -5,6 +5,8 @@ test('Testing formatDuration', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof formatDuration === 'function', 'formatDuration is a Function');
t.equal(formatDuration(1001), '1 second, 1 millisecond', "Returns the human readable format of the given number of milliseconds");
t.equal(formatDuration(34325055574), '397 days, 6 hours, 44 minutes, 15 seconds, 574 milliseconds', "Returns the human readable format of the given number of milliseconds");
//t.deepEqual(formatDuration(args..), 'Expected');
//t.equal(formatDuration(args..), 'Expected');
//t.false(formatDuration(args..), 'Expected');

View File

@ -5,6 +5,9 @@ test('Testing fromCamelCase', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof fromCamelCase === 'function', 'fromCamelCase is a Function');
t.equal(fromCamelCase('someDatabaseFieldName', ' '), 'some database field name', "Converts a string from camelcase");
t.equal(fromCamelCase('someLabelThatNeedsToBeCamelized', '-'), 'some-label-that-needs-to-be-camelized', "Converts a string from camelcase");
t.equal(fromCamelCase('someJavascriptProperty', '_'), 'some_javascript_property', "Converts a string from camelcase");
//t.deepEqual(fromCamelCase(args..), 'Expected');
//t.equal(fromCamelCase(args..), 'Expected');
//t.false(fromCamelCase(args..), 'Expected');

View File

@ -1,4 +1,4 @@
module.exports = (...arr) => {
const _gcd = (x, y) => (!y ? x : gcd(y, x % y));
const _gcd = (x, y) => (!y ? x : _gcd(y, x % y));
return [...arr].reduce((a, b) => _gcd(a, b));
};

View File

@ -5,6 +5,8 @@ test('Testing gcd', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof gcd === 'function', 'gcd is a Function');
t.equal(gcd(8, 36), 4, "Calculates the greatest common divisor between two or more numbers/arrays");
t.deepEqual(gcd(...[12, 8, 32]), 4, "Calculates the greatest common divisor between two or more numbers/arrays");
//t.deepEqual(gcd(args..), 'Expected');
//t.equal(gcd(args..), 'Expected');
//t.false(gcd(args..), 'Expected');

View File

@ -5,6 +5,9 @@ test('Testing geometricProgression', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof geometricProgression === 'function', 'geometricProgression is a Function');
t.deepEqual(geometricProgression(256), [1, 2, 4, 8, 16, 32, 64, 128, 256], "Initializes an array containing the numbers in the specified range");
t.deepEqual(geometricProgression(256, 3), [3, 6, 12, 24, 48, 96, 192], "Initializes an array containing the numbers in the specified range");
t.deepEqual(geometricProgression(256, 1, 4), [1, 4, 16, 64, 256], "Initializes an array containing the numbers in the specified range");
//t.deepEqual(geometricProgression(args..), 'Expected');
//t.equal(geometricProgression(args..), 'Expected');
//t.false(geometricProgression(args..), 'Expected');

View File

@ -5,6 +5,7 @@ test('Testing getDaysDiffBetweenDates', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof getDaysDiffBetweenDates === 'function', 'getDaysDiffBetweenDates is a Function');
t.equal(getDaysDiffBetweenDates(new Date('2017-12-13'), new Date('2017-12-22')), 9, "Returns the difference in days between two dates");
//t.deepEqual(getDaysDiffBetweenDates(args..), 'Expected');
//t.equal(getDaysDiffBetweenDates(args..), 'Expected');
//t.false(getDaysDiffBetweenDates(args..), 'Expected');

View File

@ -5,6 +5,7 @@ test('Testing getType', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof getType === 'function', 'getType is a Function');
t.equal(getType(new Set([1, 2, 3])), 'set', "Returns the native type of a value");
//t.deepEqual(getType(args..), 'Expected');
//t.equal(getType(args..), 'Expected');
//t.false(getType(args..), 'Expected');

View File

@ -5,6 +5,7 @@ test('Testing getURLParameters', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof getURLParameters === 'function', 'getURLParameters is a Function');
t.deepEqual(getURLParameters('http://url.com/page?name=Adam&surname=Smith'), {name: 'Adam', surname: 'Smith'}, "Returns an object containing the parameters of the current URL");
//t.deepEqual(getURLParameters(args..), 'Expected');
//t.equal(getURLParameters(args..), 'Expected');
//t.false(getURLParameters(args..), 'Expected');

View File

@ -5,6 +5,8 @@ test('Testing groupBy', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof groupBy === 'function', 'groupBy is a Function');
t.deepEqual(groupBy([6.1, 4.2, 6.3], Math.floor), {4: [4.2], 6: [6.1, 6.3]}, "Groups the elements of an array based on the given function");
t.deepEqual(groupBy(['one', 'two', 'three'], 'length'), {3: ['one', 'two'], 5: ['three']}, "Groups the elements of an array based on the given function");
//t.deepEqual(groupBy(args..), 'Expected');
//t.equal(groupBy(args..), 'Expected');
//t.false(groupBy(args..), 'Expected');

View File

@ -5,6 +5,7 @@ test('Testing hammingDistance', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof hammingDistance === 'function', 'hammingDistance is a Function');
t.equal(hammingDistance(2, 3), 1, "retuns hamming disance between 2 values");
//t.deepEqual(hammingDistance(args..), 'Expected');
//t.equal(hammingDistance(args..), 'Expected');
//t.false(hammingDistance(args..), 'Expected');

View File

@ -5,6 +5,7 @@ test('Testing head', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof head === 'function', 'head is a Function');
t.equal(head([1, 2, 3]), 1, "Returns head of a list");
//t.deepEqual(head(args..), 'Expected');
//t.equal(head(args..), 'Expected');
//t.false(head(args..), 'Expected');

View File

@ -5,6 +5,9 @@ test('Testing hexToRGB', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof hexToRGB === 'function', 'hexToRGB is a Function');
t.equal(hexToRGB('#27ae60ff'), 'rgba(39, 174, 96, 255)', "Converts a color code to a rgb() or rgba() string");
t.equal(hexToRGB('27ae60'), 'rgb(39, 174, 96)', "Converts a color code to a rgb() or rgba() string");
t.equal(hexToRGB('#fff'), 'rgb(255, 255, 255)', "Converts a color code to a rgb() or rgba() string");
//t.deepEqual(hexToRGB(args..), 'Expected');
//t.equal(hexToRGB(args..), 'Expected');
//t.false(hexToRGB(args..), 'Expected');

View File

@ -5,6 +5,10 @@ test('Testing inRange', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof inRange === 'function', 'inRange is a Function');
t.equal(inRange(3, 2, 5), true, "The given number falls within the given range");
t.equal(inRange(3, 4), true, "The given number falls within the given range");
t.equal(inRange(2, 3, 5), false, "The given number does not falls within the given range");
t.equal(inRange(3, 2), false, "The given number does not falls within the given range");
//t.deepEqual(inRange(args..), 'Expected');
//t.equal(inRange(args..), 'Expected');
//t.false(inRange(args..), 'Expected');

View File

@ -5,6 +5,8 @@ test('Testing indexOfAll', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof indexOfAll === 'function', 'indexOfAll is a Function');
t.deepEqual(indexOfAll([1, 2, 3, 1, 2, 3], 1), [0,3], "Returns all indices of val in an array");
t.deepEqual(indexOfAll([1, 2, 3], 4), [], "Returns all indices of val in an array");
//t.deepEqual(indexOfAll(args..), 'Expected');
//t.equal(indexOfAll(args..), 'Expected');
//t.false(indexOfAll(args..), 'Expected');

View File

@ -5,6 +5,7 @@ test('Testing initial', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof initial === 'function', 'initial is a Function');
t.deepEqual(initial([1, 2, 3]), [1, 2], "Returns all the elements of an array except the last one");
//t.deepEqual(initial(args..), 'Expected');
//t.equal(initial(args..), 'Expected');
//t.false(initial(args..), 'Expected');

View File

@ -5,6 +5,7 @@ test('Testing initialize2DArray', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof initialize2DArray === 'function', 'initialize2DArray is a Function');
t.deepEqual(initialize2DArray(2, 2, 0), [[0,0], [0,0]], "Initializes a 2D array of given width and height and value");
//t.deepEqual(initialize2DArray(args..), 'Expected');
//t.equal(initialize2DArray(args..), 'Expected');
//t.false(initialize2DArray(args..), 'Expected');

View File

@ -5,6 +5,7 @@ test('Testing initializeArrayWithRange', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof initializeArrayWithRange === 'function', 'initializeArrayWithRange is a Function');
t.deepEqual(initializeArrayWithRange(5), [0, 1, 2, 3, 4, 5], "Initializes an array containing the numbers in the specified range");
//t.deepEqual(initializeArrayWithRange(args..), 'Expected');
//t.equal(initializeArrayWithRange(args..), 'Expected');
//t.false(initializeArrayWithRange(args..), 'Expected');

View File

@ -5,6 +5,7 @@ test('Testing initializeArrayWithValues', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof initializeArrayWithValues === 'function', 'initializeArrayWithValues is a Function');
t.deepEqual(initializeArrayWithValues(5, 2), [2, 2, 2, 2, 2], "Initializes and fills an array with the specified values");
//t.deepEqual(initializeArrayWithValues(args..), 'Expected');
//t.equal(initializeArrayWithValues(args..), 'Expected');
//t.false(initializeArrayWithValues(args..), 'Expected');

View File

@ -5,6 +5,7 @@ test('Testing intersection', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof intersection === 'function', 'intersection is a Function');
t.deepEqual(intersection([1, 2, 3], [4, 3, 2]), [2, 3], "Returns a list of elements that exist in both arrays");
//t.deepEqual(intersection(args..), 'Expected');
//t.equal(intersection(args..), 'Expected');
//t.false(intersection(args..), 'Expected');

View File

@ -5,6 +5,7 @@ test('Testing invertKeyValues', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof invertKeyValues === 'function', 'invertKeyValues is a Function');
t.deepEqual(invertKeyValues({ name: 'John', age: 20 }), { 20: 'age', John: 'name' }, "Inverts the key-value pairs of an object");
//t.deepEqual(invertKeyValues(args..), 'Expected');
//t.equal(invertKeyValues(args..), 'Expected');
//t.false(invertKeyValues(args..), 'Expected');

View File

@ -5,6 +5,9 @@ test('Testing isAbsoluteURL', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof isAbsoluteURL === 'function', 'isAbsoluteURL is a Function');
t.equal(isAbsoluteURL('https://google.com'), true, "Given string is an absolute URL");
t.equal(isAbsoluteURL('ftp://www.myserver.net'), true, "Given string is an absolute URL");
t.equal(isAbsoluteURL('/foo/bar'), false, "Given string is not an absolute URL");
//t.deepEqual(isAbsoluteURL(args..), 'Expected');
//t.equal(isAbsoluteURL(args..), 'Expected');
//t.false(isAbsoluteURL(args..), 'Expected');

View File

@ -5,7 +5,8 @@ test('Testing isArray', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof isArray === 'function', 'isArray is a Function');
//t.deepEqual(isArray(args..), 'Expected');
t.equal(isArray([1]), true, "passed value is an array");
t.equal(isArray('array'), false, "passed value is not an array");
//t.equal(isArray(args..), 'Expected');
//t.false(isArray(args..), 'Expected');
//t.throws(isArray(args..), 'Expected');

View File

@ -5,6 +5,8 @@ test('Testing isBoolean', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof isBoolean === 'function', 'isBoolean is a Function');
t.equal(isBoolean(null), false, "passed value is not a boolean");
t.equal(isBoolean(false), true, "passed value is not a boolean");
//t.deepEqual(isBoolean(args..), 'Expected');
//t.equal(isBoolean(args..), 'Expected');
//t.false(isBoolean(args..), 'Expected');

View File

@ -5,7 +5,8 @@ test('Testing isFunction', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof isFunction === 'function', 'isFunction is a Function');
//t.deepEqual(isFunction(args..), 'Expected');
t.equal(isFunction(x => x), true, "passed value is a function");
t.equal(isFunction('x'), false, "passed value is not a function");
//t.equal(isFunction(args..), 'Expected');
//t.false(isFunction(args..), 'Expected');
//t.throws(isFunction(args..), 'Expected');

View File

@ -5,6 +5,9 @@ test('Testing isLowerCase', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof isLowerCase === 'function', 'isLowerCase is a Function');
t.equal(isLowerCase('abc'), true, "passed string is a lowercase");
t.equal(isLowerCase('a3@$'), true, "passed string is a lowercase");
t.equal(isLowerCase('A3@$'), false, "passed value is not a lowercase");
//t.deepEqual(isLowerCase(args..), 'Expected');
//t.equal(isLowerCase(args..), 'Expected');
//t.false(isLowerCase(args..), 'Expected');

View File

@ -5,6 +5,8 @@ test('Testing isNull', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof isNull === 'function', 'isNull is a Function');
t.equal(isNull(null), true, "passed argument is a null");
t.equal(isNull(NaN), false, "passed argument is a null");
//t.deepEqual(isNull(args..), 'Expected');
//t.equal(isNull(args..), 'Expected');
//t.false(isNull(args..), 'Expected');

View File

@ -5,6 +5,9 @@ test('Testing isNumber', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof isNumber === 'function', 'isNumber is a Function');
t.equal(isNumber(1), true, "passed argument is a number");
t.equal(isNumber('1'), false, "passed argument is not a number");
//t.deepEqual(isNumber(args..), 'Expected');
//t.equal(isNumber(args..), 'Expected');
//t.false(isNumber(args..), 'Expected');