Merge pull request #524 from Chalarangelo/snippet-tests
[FEATURE] Snippet tests
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
### isPrimitive
|
||||
|
||||
Returns a boolean determining if the supplied value is primitive or not.
|
||||
Returns a boolean determining if the passed value is primitive or not.
|
||||
|
||||
Use `Array.includes()` on an array of type strings which are not primitive,
|
||||
supplying the type using `typeof`.
|
||||
|
||||
@ -23,6 +23,6 @@ const luhnCheck = num => {
|
||||
|
||||
```js
|
||||
luhnCheck('4485275742308327'); // true
|
||||
luhnCheck(6011329933655299); // true
|
||||
luhnCheck(6011329933655299); // false
|
||||
luhnCheck(123456789); // false
|
||||
```
|
||||
|
||||
@ -15,5 +15,5 @@ const mask = (cc, num = 4, mask = '*') =>
|
||||
```js
|
||||
mask(1234567890); // '******7890'
|
||||
mask(1234567890, 3); // '*******890'
|
||||
mask(1234567890, -4, '$'); // '1234$$$$$$'
|
||||
mask(1234567890, -4, '$'); // '$$$$567890'
|
||||
```
|
||||
|
||||
@ -9,5 +9,5 @@ const objectToPairs = obj => Object.keys(obj).map(k => [k, obj[k]]);
|
||||
```
|
||||
|
||||
```js
|
||||
objectToPairs({ a: 1, b: 2 }); // [['a',1],['b',2]])
|
||||
objectToPairs({ a: 1, b: 2 }); // [['a',1],['b',2]]
|
||||
```
|
||||
|
||||
@ -17,6 +17,6 @@ const partition = (arr, fn) =>
|
||||
```
|
||||
|
||||
```js
|
||||
var users = [{ user: 'barney', age: 36, active: false }, { user: 'fred', age: 40, active: true }];
|
||||
const users = [{ user: 'barney', age: 36, active: false }, { user: 'fred', age: 40, active: true }];
|
||||
partition(users, o => o.active); // [[{ 'user': 'fred', 'age': 40, 'active': true }],[{ 'user': 'barney', 'age': 36, 'active': false }]]
|
||||
```
|
||||
|
||||
@ -19,7 +19,7 @@ const prettyBytes = (num, precision = 3, addSpace = true) => {
|
||||
```
|
||||
|
||||
```js
|
||||
prettyBytes(1000); // 1 KB
|
||||
prettyBytes(-27145424323.5821, 5); // -27.145 GB
|
||||
prettyBytes(123456789, 3, false); // 123MB
|
||||
prettyBytes(1000); // "1 KB"
|
||||
prettyBytes(-27145424323.5821, 5); // "-27.145 GB"
|
||||
prettyBytes(123456789, 3, false); // "123MB"
|
||||
```
|
||||
|
||||
@ -16,5 +16,5 @@ const sdbm = str => {
|
||||
```
|
||||
|
||||
```js
|
||||
console.log(sdbm('name')); // -3521204949
|
||||
sdbm('name'); // -3521204949
|
||||
```
|
||||
|
||||
@ -9,5 +9,5 @@ const splitLines = str => str.split(/\r?\n/);
|
||||
```
|
||||
|
||||
```js
|
||||
splitLines('This\nis a\nmultiline\nstring.\n'); // ['This', 'is a', 'multiline', 'string' , '']
|
||||
splitLines('This\nis a\nmultiline\nstring.\n'); // ['This', 'is a', 'multiline', 'string.' , '']
|
||||
```
|
||||
|
||||
@ -7,5 +7,5 @@ const toDecimalMark = num => num.toLocaleString('en-US');
|
||||
```
|
||||
|
||||
```js
|
||||
toDecimalMark(12305030388.9087); // "12,305,030,388.9087"
|
||||
toDecimalMark(12305030388.9087); // "12,305,030,388.909"
|
||||
```
|
||||
|
||||
@ -5,6 +5,7 @@ test('Testing RGBToHex', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof RGBToHex === 'function', 'RGBToHex is a Function');
|
||||
t.equal(RGBToHex(255, 165, 1), 'ffa501', "Converts the values of RGB components to a color code.");
|
||||
//t.deepEqual(RGBToHex(args..), 'Expected');
|
||||
//t.equal(RGBToHex(args..), 'Expected');
|
||||
//t.false(RGBToHex(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,7 @@ test('Testing isPrime', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof isPrime === 'function', 'isPrime is a Function');
|
||||
t.equal(isPrime(11), true, "passed number is a prime");
|
||||
//t.deepEqual(isPrime(args..), 'Expected');
|
||||
//t.equal(isPrime(args..), 'Expected');
|
||||
//t.false(isPrime(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,14 @@ test('Testing isPrimitive', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof isPrimitive === 'function', 'isPrimitive is a Function');
|
||||
t.equal(isPrimitive(null), true, "passed value is primitive");
|
||||
t.equal(isPrimitive(50), true, "passed value is primitive");
|
||||
t.equal(isPrimitive('Hello'), true, "passed value is primitive");
|
||||
t.equal(isPrimitive(false), true, "passed value is primitive");
|
||||
t.equal(isPrimitive(Symbol()), true, "passed value is primitive");
|
||||
t.equal(isPrimitive([]), false, "passed value is primitive");
|
||||
|
||||
|
||||
//t.deepEqual(isPrimitive(args..), 'Expected');
|
||||
//t.equal(isPrimitive(args..), 'Expected');
|
||||
//t.false(isPrimitive(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,7 @@ test('Testing isSymbol', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof isSymbol === 'function', 'isSymbol is a Function');
|
||||
t.equal(isSymbol(Symbol('x')), true, "Checks if the given argument is a symbol");
|
||||
//t.deepEqual(isSymbol(args..), 'Expected');
|
||||
//t.equal(isSymbol(args..), 'Expected');
|
||||
//t.false(isSymbol(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,10 @@ test('Testing join', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof join === 'function', 'join is a Function');
|
||||
t.deepEqual(join(['pen', 'pineapple', 'apple', 'pen'], ',', '&'), "pen,pineapple,apple&pen", "Joins all elements of an array into a string and returns this string");
|
||||
t.deepEqual(join(['pen', 'pineapple', 'apple', 'pen'], ','), "pen,pineapple,apple,pen", "Joins all elements of an array into a string and returns this string");
|
||||
t.deepEqual(join(['pen', 'pineapple', 'apple', 'pen']), "pen,pineapple,apple,pen", "Joins all elements of an array into a string and returns this string");
|
||||
|
||||
//t.deepEqual(join(args..), 'Expected');
|
||||
//t.equal(join(args..), 'Expected');
|
||||
//t.false(join(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,7 @@ test('Testing last', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof last === 'function', 'last is a Function');
|
||||
t.equal(last([1, 2, 3]), 3, "Returns the last element in an array");
|
||||
//t.deepEqual(last(args..), 'Expected');
|
||||
//t.equal(last(args..), 'Expected');
|
||||
//t.false(last(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,8 @@ test('Testing lcm', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof lcm === 'function', 'lcm is a Function');
|
||||
t.equal(lcm(12, 7), 84, "Returns the least common multiple of two or more numbers.");
|
||||
t.equal(lcm(...[1, 3, 4, 5]), 60, "Returns the least common multiple of two or more numbers.");
|
||||
//t.deepEqual(lcm(args..), 'Expected');
|
||||
//t.equal(lcm(args..), 'Expected');
|
||||
//t.false(lcm(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,7 @@ test('Testing longestItem', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof longestItem === 'function', 'longestItem is a Function');
|
||||
t.deepEqual(longestItem('this', 'is', 'a', 'testcase'), 'testcase', "Returns the longest object");
|
||||
//t.deepEqual(longestItem(args..), 'Expected');
|
||||
//t.equal(longestItem(args..), 'Expected');
|
||||
//t.false(longestItem(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,9 @@ test('Testing luhnCheck', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof luhnCheck === 'function', 'luhnCheck is a Function');
|
||||
t.equal(luhnCheck(6011329933655299), false, "validates identification number");
|
||||
t.equal(luhnCheck('4485275742308327'), true, "validates identification number");
|
||||
t.equal(luhnCheck(123456789), false, "validates identification number");
|
||||
//t.deepEqual(luhnCheck(args..), 'Expected');
|
||||
//t.equal(luhnCheck(args..), 'Expected');
|
||||
//t.false(luhnCheck(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,8 @@ test('Testing mapObject', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof mapObject === 'function', 'mapObject is a Function');
|
||||
const squareIt = arr => mapObject(arr, a => a * a);
|
||||
t.deepEqual(squareIt([1, 2, 3]), { 1: 1, 2: 4, 3: 9 }, "Maps the values of an array to an object using a function");
|
||||
//t.deepEqual(mapObject(args..), 'Expected');
|
||||
//t.equal(mapObject(args..), 'Expected');
|
||||
//t.false(mapObject(args..), 'Expected');
|
||||
|
||||
@ -5,7 +5,10 @@ test('Testing mask', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof mask === 'function', 'mask is a Function');
|
||||
//t.deepEqual(mask(args..), 'Expected');
|
||||
t.equal(mask(1234567890), '******7890', "Replaces all but the last num of characters with the specified mask character");
|
||||
t.equal(mask(1234567890, 3), '*******890', "Replaces all but the last num of characters with the specified mask character");
|
||||
t.equal(mask(1234567890, -4, '$'), '$$$$567890', "Replaces all but the last num of characters with the specified mask character");
|
||||
|
||||
//t.equal(mask(args..), 'Expected');
|
||||
//t.false(mask(args..), 'Expected');
|
||||
//t.throws(mask(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,8 @@ test('Testing maxN', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof maxN === 'function', 'maxN is a Function');
|
||||
t.deepEqual(maxN([1, 2, 3]), [3], "Returns the n maximum elements from the provided array");
|
||||
t.deepEqual(maxN([1, 2, 3], 2), [3, 2], "Returns the n maximum elements from the provided array");
|
||||
//t.deepEqual(maxN(args..), 'Expected');
|
||||
//t.equal(maxN(args..), 'Expected');
|
||||
//t.false(maxN(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,8 @@ test('Testing median', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof median === 'function', 'median is a Function');
|
||||
t.equal(median([5, 6, 50, 1, -5]), 5, "Returns the median of an array of numbers");
|
||||
t.equal(median([1, 2, 3]), 2, "Returns the median of an array of numbers");
|
||||
//t.deepEqual(median(args..), 'Expected');
|
||||
//t.equal(median(args..), 'Expected');
|
||||
//t.false(median(args..), 'Expected');
|
||||
|
||||
@ -5,7 +5,8 @@ test('Testing minN', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof minN === 'function', 'minN is a Function');
|
||||
//t.deepEqual(minN(args..), 'Expected');
|
||||
t.deepEqual(minN([1, 2, 3]), [1], "Returns the n minimum elements from the provided array");
|
||||
t.deepEqual(minN([1, 2, 3], 2), [1, 2], "Returns the n minimum elements from the provided array");
|
||||
//t.equal(minN(args..), 'Expected');
|
||||
//t.false(minN(args..), 'Expected');
|
||||
//t.throws(minN(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,7 @@ test('Testing negate', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof negate === 'function', 'negate is a Function');
|
||||
t.deepEqual([1, 2, 3, 4, 5, 6].filter(negate(n => n % 2 == 0)), [1, 3, 5], "Negates a predicate function");
|
||||
//t.deepEqual(negate(args..), 'Expected');
|
||||
//t.equal(negate(args..), 'Expected');
|
||||
//t.false(negate(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,8 @@ test('Testing nthElement', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof nthElement === 'function', 'nthElement is a Function');
|
||||
t.equal(nthElement(['a', 'b', 'c'], 1), 'b', "Returns the nth element of an array.");
|
||||
t.equal(nthElement(['a', 'b', 'c'], -3), 'a', "Returns the nth element of an array.");
|
||||
//t.deepEqual(nthElement(args..), 'Expected');
|
||||
//t.equal(nthElement(args..), 'Expected');
|
||||
//t.false(nthElement(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,7 @@ test('Testing objectFromPairs', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof objectFromPairs === 'function', 'objectFromPairs is a Function');
|
||||
t.deepEqual(objectFromPairs([['a', 1], ['b', 2]]), {a: 1, b: 2}, "Creates an object from the given key-value pairs.");
|
||||
//t.deepEqual(objectFromPairs(args..), 'Expected');
|
||||
//t.equal(objectFromPairs(args..), 'Expected');
|
||||
//t.false(objectFromPairs(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,7 @@ test('Testing objectToPairs', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof objectToPairs === 'function', 'objectToPairs is a Function');
|
||||
t.deepEqual(objectToPairs({ a: 1, b: 2 }), [['a',1],['b',2]], "Creates an array of key-value pair arrays from an object.");
|
||||
//t.deepEqual(objectToPairs(args..), 'Expected');
|
||||
//t.equal(objectToPairs(args..), 'Expected');
|
||||
//t.false(objectToPairs(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,9 @@ test('Testing orderBy', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof orderBy === 'function', 'orderBy is a Function');
|
||||
const users = [{ name: 'fred', age: 48 }, { name: 'barney', age: 36 }, { name: 'fred', age: 40 }];
|
||||
t.deepEqual(orderBy(users, ['name', 'age'], ['asc', 'desc']), [{name: 'barney', age: 36}, {name: 'fred', age: 48}, {name: 'fred', age: 40}], "Returns a sorted array of objects ordered by properties and orders.");
|
||||
t.deepEqual(orderBy(users, ['name', 'age']), [{name: 'barney', age: 36}, {name: 'fred', age: 40}, {name: 'fred', age: 48}], "Returns a sorted array of objects ordered by properties and orders.");
|
||||
//t.deepEqual(orderBy(args..), 'Expected');
|
||||
//t.equal(orderBy(args..), 'Expected');
|
||||
//t.false(orderBy(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,8 @@ test('Testing palindrome', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof palindrome === 'function', 'palindrome is a Function');
|
||||
t.equal(palindrome('taco cat'), true, "Given string is a palindrome");
|
||||
t.equal(palindrome('foobar'), false, "Given string is not a palindrome");
|
||||
//t.deepEqual(palindrome(args..), 'Expected');
|
||||
//t.equal(palindrome(args..), 'Expected');
|
||||
//t.false(palindrome(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,8 @@ test('Testing partition', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof partition === 'function', 'partition is a Function');
|
||||
const users = [{ user: 'barney', age: 36, active: false }, { user: 'fred', age: 40, active: true }];
|
||||
t.deepEqual(partition(users, o => o.active), [[{ 'user': 'fred', 'age': 40, 'active': true }],[{ 'user': 'barney', 'age': 36, 'active': false }]], "Groups the elements into two arrays, depending on the provided function's truthiness for each element.");
|
||||
//t.deepEqual(partition(args..), 'Expected');
|
||||
//t.equal(partition(args..), 'Expected');
|
||||
//t.false(partition(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,7 @@ test('Testing percentile', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof percentile === 'function', 'percentile is a Function');
|
||||
t.equal(percentile([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 6), 55, "Uses the percentile formula to calculate how many numbers in the given array are less or equal to the given value.");
|
||||
//t.deepEqual(percentile(args..), 'Expected');
|
||||
//t.equal(percentile(args..), 'Expected');
|
||||
//t.false(percentile(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,7 @@ test('Testing pick', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof pick === 'function', 'pick is a Function');
|
||||
t.deepEqual(pick({ a: 1, b: '2', c: 3 }, ['a', 'c']), { 'a': 1, 'c': 3 }, "Picks the key-value pairs corresponding to the given keys from an object.");
|
||||
//t.deepEqual(pick(args..), 'Expected');
|
||||
//t.equal(pick(args..), 'Expected');
|
||||
//t.false(pick(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,7 @@ test('Testing powerset', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof powerset === 'function', 'powerset is a Function');
|
||||
t.deepEqual(powerset([1, 2]), [[], [1], [2], [2,1]], "Returns the powerset of a given array of numbers.");
|
||||
//t.deepEqual(powerset(args..), 'Expected');
|
||||
//t.equal(powerset(args..), 'Expected');
|
||||
//t.false(powerset(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,10 @@ test('Testing prettyBytes', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof prettyBytes === 'function', 'prettyBytes is a Function');
|
||||
t.equal(prettyBytes(1000), '1 KB', "Converts a number in bytes to a human-readable string.");
|
||||
t.equal(prettyBytes(-27145424323.5821, 5), '-27.145 GB', "Converts a number in bytes to a human-readable string.");
|
||||
t.equal(prettyBytes(123456789, 3, false), '123MB', "Converts a number in bytes to a human-readable string.");
|
||||
|
||||
//t.deepEqual(prettyBytes(args..), 'Expected');
|
||||
//t.equal(prettyBytes(args..), 'Expected');
|
||||
//t.false(prettyBytes(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,7 @@ test('Testing primes', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof primes === 'function', 'primes is a Function');
|
||||
t.deepEqual(primes(10), [2, 3, 5, 7], "Generates primes up to a given number, using the Sieve of Eratosthenes.");
|
||||
//t.deepEqual(primes(args..), 'Expected');
|
||||
//t.equal(primes(args..), 'Expected');
|
||||
//t.false(primes(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,19 @@ test('Testing reducedFilter', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof reducedFilter === 'function', 'reducedFilter is a Function');
|
||||
const data = [
|
||||
{
|
||||
id: 1,
|
||||
name: 'john',
|
||||
age: 24
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: 'mike',
|
||||
age: 50
|
||||
}
|
||||
];
|
||||
t.deepEqual(reducedFilter(data, ['id', 'name'], item => item.age > 24), [{ id: 2, name: 'mike'}], "Filter an array of objects based on a condition while also filtering out unspecified keys.");
|
||||
//t.deepEqual(reducedFilter(args..), 'Expected');
|
||||
//t.equal(reducedFilter(args..), 'Expected');
|
||||
//t.false(reducedFilter(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,7 @@ test('Testing remove', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof remove === 'function', 'remove is a Function');
|
||||
t.deepEqual(remove([1, 2, 3, 4], n => n % 2 == 0), [2, 4], "Removes elements from an array for which the given function returns false");
|
||||
//t.deepEqual(remove(args..), 'Expected');
|
||||
//t.equal(remove(args..), 'Expected');
|
||||
//t.false(remove(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,7 @@ test('Testing reverseString', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof reverseString === 'function', 'reverseString is a Function');
|
||||
t.equal(reverseString('foobar'), 'raboof', "Reverses a string.");
|
||||
//t.deepEqual(reverseString(args..), 'Expected');
|
||||
//t.equal(reverseString(args..), 'Expected');
|
||||
//t.false(reverseString(args..), 'Expected');
|
||||
|
||||
@ -5,7 +5,7 @@ test('Testing round', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof round === 'function', 'round is a Function');
|
||||
//t.deepEqual(round(args..), 'Expected');
|
||||
t.equal(round(1.005, 2), 1.01, "Rounds a number to a specified amount of digits.");
|
||||
//t.equal(round(args..), 'Expected');
|
||||
//t.false(round(args..), 'Expected');
|
||||
//t.throws(round(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,7 @@ test('Testing sdbm', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof sdbm === 'function', 'sdbm is a Function');
|
||||
t.equal(sdbm('name'), -3521204949, "Hashes the input string into a whole number.");
|
||||
//t.deepEqual(sdbm(args..), 'Expected');
|
||||
//t.equal(sdbm(args..), 'Expected');
|
||||
//t.false(sdbm(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,8 @@ test('Testing select', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof select === 'function', 'select is a Function');
|
||||
const obj = { selector: { to: { val: 'val to select' } } };
|
||||
t.equal(select(obj, 'selector.to.val'), 'val to select', "Retrieve a property indicated by the selector from an object.");
|
||||
//t.deepEqual(select(args..), 'Expected');
|
||||
//t.equal(select(args..), 'Expected');
|
||||
//t.false(select(args..), 'Expected');
|
||||
|
||||
@ -5,8 +5,7 @@ test('Testing similarity', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof similarity === 'function', 'similarity is a Function');
|
||||
//t.deepEqual(similarity(args..), 'Expected');
|
||||
//t.equal(similarity(args..), 'Expected');
|
||||
t.deepEqual(similarity([1, 2, 3], [1, 2, 4]), [1, 2], "Returns an array of elements that appear in both arrays."); //t.equal(similarity(args..), 'Expected');
|
||||
//t.false(similarity(args..), 'Expected');
|
||||
//t.throws(similarity(args..), 'Expected');
|
||||
t.end();
|
||||
|
||||
@ -5,6 +5,10 @@ test('Testing size', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof size === 'function', 'size is a Function');
|
||||
t.equal(size([1, 2, 3, 4, 5]), 5, "Get size of arrays, objects or strings.");
|
||||
// t.equal(size('size'), 4, "Get size of arrays, objects or strings."); DOESN'T WORK IN NODE ENV
|
||||
t.equal(size({ one: 1, two: 2, three: 3 }), 3, "Get size of arrays, objects or strings.");
|
||||
|
||||
//t.deepEqual(size(args..), 'Expected');
|
||||
//t.equal(size(args..), 'Expected');
|
||||
//t.false(size(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,7 @@ test('Testing sortCharactersInString', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof sortCharactersInString === 'function', 'sortCharactersInString is a Function');
|
||||
t.equal(sortCharactersInString('cabbage'), 'aabbceg', "Alphabetically sorts the characters in a string.");
|
||||
//t.deepEqual(sortCharactersInString(args..), 'Expected');
|
||||
//t.equal(sortCharactersInString(args..), 'Expected');
|
||||
//t.false(sortCharactersInString(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,8 @@ test('Testing sortedIndex', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof sortedIndex === 'function', 'sortedIndex is a Function');
|
||||
t.equal(sortedIndex([5, 3, 2, 1], 4), 1, "Returns the lowest index at which value should be inserted into array in order to maintain its sort order.");
|
||||
t.equal(sortedIndex([30, 50], 40), 1, "Returns the lowest index at which value should be inserted into array in order to maintain its sort order.");
|
||||
//t.deepEqual(sortedIndex(args..), 'Expected');
|
||||
//t.equal(sortedIndex(args..), 'Expected');
|
||||
//t.false(sortedIndex(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,7 @@ test('Testing splitLines', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof splitLines === 'function', 'splitLines is a Function');
|
||||
t.deepEqual(splitLines('This\nis a\nmultiline\nstring.\n'), ['This', 'is a', 'multiline', 'string.' , ''], "Splits a multiline string into an array of lines.");
|
||||
//t.deepEqual(splitLines(args..), 'Expected');
|
||||
//t.equal(splitLines(args..), 'Expected');
|
||||
//t.false(splitLines(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,8 @@ test('Testing spreadOver', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof spreadOver === 'function', 'spreadOver is a Function');
|
||||
const arrayMax = spreadOver(Math.max);
|
||||
t.equal(arrayMax([1, 2, 3]), 3, "Takes a variadic function and returns a closure that accepts an array of arguments to map to the inputs of the function.");
|
||||
//t.deepEqual(spreadOver(args..), 'Expected');
|
||||
//t.equal(spreadOver(args..), 'Expected');
|
||||
//t.false(spreadOver(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,8 @@ test('Testing standardDeviation', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof standardDeviation === 'function', 'standardDeviation is a Function');
|
||||
t.equal(standardDeviation([10, 2, 38, 23, 38, 23, 21]), 13.284434142114991, "Returns the standard deviation of an array of numbers");
|
||||
t.equal(standardDeviation([10, 2, 38, 23, 38, 23, 21], true), 12.29899614287479, "Returns the standard deviation of an array of numbers");
|
||||
//t.deepEqual(standardDeviation(args..), 'Expected');
|
||||
//t.equal(standardDeviation(args..), 'Expected');
|
||||
//t.false(standardDeviation(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,7 @@ test('Testing sum', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof sum === 'function', 'sum is a Function');
|
||||
t.equal(sum(...[1, 2, 3, 4]), 10, "Returns the sum of two or more numbers/arrays.");
|
||||
//t.deepEqual(sum(args..), 'Expected');
|
||||
//t.equal(sum(args..), 'Expected');
|
||||
//t.false(sum(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,9 @@ test('Testing sumPower', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof sumPower === 'function', 'sumPower is a Function');
|
||||
t.equal(sumPower(10), 385, "Returns the sum of the powers of all the numbers from start to end");
|
||||
t.equal(sumPower(10, 3), 3025, "Returns the sum of the powers of all the numbers from start to end");
|
||||
t.equal(sumPower(10, 3, 5), 2925, "Returns the sum of the powers of all the numbers from start to end");
|
||||
//t.deepEqual(sumPower(args..), 'Expected');
|
||||
//t.equal(sumPower(args..), 'Expected');
|
||||
//t.false(sumPower(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,7 @@ test('Testing symmetricDifference', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof symmetricDifference === 'function', 'symmetricDifference is a Function');
|
||||
t.deepEqual(symmetricDifference([1, 2, 3], [1, 2, 4]), [3, 4], "Returns the symmetric difference between two arrays.");
|
||||
//t.deepEqual(symmetricDifference(args..), 'Expected');
|
||||
//t.equal(symmetricDifference(args..), 'Expected');
|
||||
//t.false(symmetricDifference(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,8 @@ test('Testing tail', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof tail === 'function', 'tail is a Function');
|
||||
t.deepEqual(tail([1, 2, 3]), [2, 3], "Returns tail");
|
||||
t.deepEqual(tail([1]), [1], "Returns tail");
|
||||
//t.deepEqual(tail(args..), 'Expected');
|
||||
//t.equal(tail(args..), 'Expected');
|
||||
//t.false(tail(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,8 @@ test('Testing take', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof take === 'function', 'take is a Function');
|
||||
t.deepEqual(take([1, 2, 3], 5), [1, 2, 3], "Returns an array with n elements removed from the beginning.")
|
||||
t.deepEqual(take([1, 2, 3], 0), [], "Returns an array with n elements removed from the beginning.")
|
||||
//t.deepEqual(take(args..), 'Expected');
|
||||
//t.equal(take(args..), 'Expected');
|
||||
//t.false(take(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,8 @@ test('Testing takeRight', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof takeRight === 'function', 'takeRight is a Function');
|
||||
t.deepEqual(takeRight([1, 2, 3], 2), [2, 3], "Returns an array with n elements removed from the end");
|
||||
t.deepEqual(takeRight([1, 2, 3]), [3], "Returns an array with n elements removed from the end");
|
||||
//t.deepEqual(takeRight(args..), 'Expected');
|
||||
//t.equal(takeRight(args..), 'Expected');
|
||||
//t.false(takeRight(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,10 @@ test('Testing toCamelCase', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof toCamelCase === 'function', 'toCamelCase is a Function');
|
||||
t.equal(toCamelCase('some_database_field_name'), 'someDatabaseFieldName', "Converts a string to camelCase");
|
||||
t.equal(toCamelCase('Some label that needs to be camelized'), 'someLabelThatNeedsToBeCamelized', "Converts a string to camelCase");
|
||||
t.equal(toCamelCase('some-javascript-property'), 'someJavascriptProperty', "Converts a string to camelCase");
|
||||
t.equal(toCamelCase('some-mixed_string with spaces_underscores-and-hyphens'), 'someMixedStringWithSpacesUnderscoresAndHyphens', "Converts a string to camelCase");
|
||||
//t.deepEqual(toCamelCase(args..), 'Expected');
|
||||
//t.equal(toCamelCase(args..), 'Expected');
|
||||
//t.false(toCamelCase(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,7 @@ test('Testing toDecimalMark', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof toDecimalMark === 'function', 'toDecimalMark is a Function');
|
||||
t.equal(toDecimalMark(12305030388.9087), "12,305,030,388.909", "convert a float-point arithmetic to the Decimal mark form");
|
||||
//t.deepEqual(toDecimalMark(args..), 'Expected');
|
||||
//t.equal(toDecimalMark(args..), 'Expected');
|
||||
//t.false(toDecimalMark(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,7 @@ test('Testing toEnglishDate', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof toEnglishDate === 'function', 'toEnglishDate is a Function');
|
||||
// t.equal(toEnglishDate('09/21/2010'), '21/09/2010', 'Converts a date from American format to English format');
|
||||
//t.deepEqual(toEnglishDate(args..), 'Expected');
|
||||
//t.equal(toEnglishDate(args..), 'Expected');
|
||||
//t.false(toEnglishDate(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,10 @@ test('Testing toKebabCase', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof toKebabCase === 'function', 'toKebabCase is a Function');
|
||||
t.equal(toKebabCase('camelCase'), 'camel-case', "string converts to snake case");
|
||||
t.equal(toKebabCase('some text'), 'some-text', "string converts to snake case");
|
||||
t.equal(toKebabCase('some-mixed-string With spaces-underscores-and-hyphens'), 'some-mixed-string-with-spaces-underscores-and-hyphens', "string converts to snake case");
|
||||
t.equal(toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML'), 'i-am-listening-to-fm-while-loading-different-url-on-my-browser-and-also-editing-some-xml-and-html', "string converts to snake case");
|
||||
//t.deepEqual(toKebabCase(args..), 'Expected');
|
||||
//t.equal(toKebabCase(args..), 'Expected');
|
||||
//t.false(toKebabCase(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,11 @@ test('Testing toSnakeCase', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof toSnakeCase === 'function', 'toSnakeCase is a Function');
|
||||
t.equal(toSnakeCase('camelCase'), 'camel_case', "string converts to snake case");
|
||||
t.equal(toSnakeCase('some text'), 'some_text', "string converts to snake case");
|
||||
t.equal(toSnakeCase('some-mixed_string With spaces_underscores-and-hyphens'), 'some_mixed_string_with_spaces_underscores_and_hyphens', "string converts to snake case");
|
||||
t.equal(toSnakeCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML'), 'i_am_listening_to_fm_while_loading_different_url_on_my_browser_and_also_editing_some_xml_and_html', "string converts to snake case");
|
||||
|
||||
//t.deepEqual(toSnakeCase(args..), 'Expected');
|
||||
//t.equal(toSnakeCase(args..), 'Expected');
|
||||
//t.false(toSnakeCase(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,7 @@ test('Testing truthCheckCollection', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof truthCheckCollection === 'function', 'truthCheckCollection is a Function');
|
||||
t.equal(truthCheckCollection([{ user: 'Tinky-Winky', sex: 'male' }, { user: 'Dipsy', sex: 'male' }], 'sex'), true, "second argument is truthy on all elements of a collection");
|
||||
//t.deepEqual(truthCheckCollection(args..), 'Expected');
|
||||
//t.equal(truthCheckCollection(args..), 'Expected');
|
||||
//t.false(truthCheckCollection(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,7 @@ test('Testing union', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof union === 'function', 'union is a Function');
|
||||
t.deepEqual(union([1, 2, 3], [4, 3, 2]), [1, 2, 3, 4], "Returns every element that exists in any of the two arrays once");
|
||||
//t.deepEqual(union(args..), 'Expected');
|
||||
//t.equal(union(args..), 'Expected');
|
||||
//t.false(union(args..), 'Expected');
|
||||
|
||||
@ -5,6 +5,7 @@ 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');
|
||||
|
||||
Reference in New Issue
Block a user