From dcc4556878f6ecd0b51b8008c9cf96fb6ca31f52 Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Mon, 18 Jun 2018 16:44:12 +0300 Subject: [PATCH] Test cleanup and fixes [e-f] --- .../elementIsVisibleInViewport.test.js | 6 +---- test/elo/elo.test.js | 16 ++++++------ test/equals/equals.test.js | 17 +++++------- test/escapeHTML/escapeHTML.test.js | 8 +++--- test/escapeRegExp/escapeRegExp.test.js | 8 +++--- test/everyNth/everyNth.test.js | 8 +++--- test/extendHex/extendHex.test.js | 12 ++++----- test/factorial/factorial.test.js | 24 ++++++++--------- test/factors/factors.test.js | 4 +-- test/fibonacci/fibonacci.test.js | 8 +++--- .../fibonacciCountUntilNum.test.js | 4 +-- .../fibonacciUntilNum.test.js | 4 +-- test/filterNonUnique/filterNonUnique.test.js | 7 +++-- test/findKey/findKey.test.js | 12 ++++----- test/findLast/findLast.test.js | 9 +++---- test/findLastIndex/findLastIndex.test.js | 9 +++---- test/findLastKey/findLastKey.test.js | 12 ++++----- test/flatten/flatten.test.js | 12 ++++----- test/flattenObject/flattenObject.test.js | 13 ++++------ test/flip/flip.test.js | 17 +++++------- test/forEachRight/forEachRight.test.js | 13 ++++------ test/forOwn/forOwn.test.js | 13 ++++------ test/forOwnRight/forOwnRight.test.js | 13 ++++------ test/formatDuration/formatDuration.test.js | 12 ++++----- test/fromCamelCase/fromCamelCase.test.js | 16 +++++------- test/functionName/functionName.test.js | 26 +++++++++---------- test/functions/functions.test.js | 23 +++++++--------- 27 files changed, 132 insertions(+), 194 deletions(-) diff --git a/test/elementIsVisibleInViewport/elementIsVisibleInViewport.test.js b/test/elementIsVisibleInViewport/elementIsVisibleInViewport.test.js index d7bc61cd5..f3d70a2fd 100644 --- a/test/elementIsVisibleInViewport/elementIsVisibleInViewport.test.js +++ b/test/elementIsVisibleInViewport/elementIsVisibleInViewport.test.js @@ -1,10 +1,6 @@ const expect = require('expect'); const elementIsVisibleInViewport = require('./elementIsVisibleInViewport.js'); - - test('elementIsVisibleInViewport is a Function', () => { +test('elementIsVisibleInViewport is a Function', () => { expect(elementIsVisibleInViewport).toBeInstanceOf(Function); }); - - - diff --git a/test/elo/elo.test.js b/test/elo/elo.test.js index 2868b5fbc..3690a3425 100644 --- a/test/elo/elo.test.js +++ b/test/elo/elo.test.js @@ -1,15 +1,15 @@ const expect = require('expect'); const elo = require('./elo.js'); - - test('elo is a Function', () => { +test('elo is a Function', () => { expect(elo).toBeInstanceOf(Function); }); - test('Standard 1v1s', () => { - expect(elo([1200, 1200]), [1216).toEqual(1184]) +test('Standard 1v1s', () => { + expect(elo([1200, 1200])).toEqual([1216,1184]); }); - t.deepEqual(elo([1200, 1200], 64), [1232, 1168]), "Standard 1v1s"; - test('4 player FFA, all same rank', () => { - expect(elo([1200, 1200, 1200, 1200]).map(Math.round), [1246, 1215, 1185).toEqual(1154]) +test('Standard 1v1s' ,() => { + expect(elo([1200, 1200], 64)).toBe([1232, 1168]); +}); +test('4 player FFA, all same rank', () => { + expect(elo([1200, 1200, 1200, 1200]).map(Math.round)).toEqual([1246, 1215, 1185, 1154]); }); - diff --git a/test/equals/equals.test.js b/test/equals/equals.test.js index c6622d169..f43d92336 100644 --- a/test/equals/equals.test.js +++ b/test/equals/equals.test.js @@ -1,24 +1,21 @@ const expect = require('expect'); const equals = require('./equals.js'); - - test('equals is a Function', () => { +test('equals is a Function', () => { expect(equals).toBeInstanceOf(Function); }); - test('{ a: [2, {e: 3}], b: [4], c: 'foo' } is equal to { a: [2, {e: 3}], b: [4], c: 'foo' }', () => { - expect(equals({ a: [2, {e: 3}], b: [4], c: 'foo' }, { a: [2, {e: 3}], b: [4], c: 'foo' })).toBeTruthy() +test('{ a: [2, {e: 3}], b: [4], c: 'foo' } is equal to { a: [2, {e: 3}], b: [4], c: 'foo' }', () => { + expect(equals({ a: [2, {e: 3}], b: [4], c: 'foo' }, { a: [2, {e: 3}], b: [4], c: 'foo' })).toBeTruthy(); }); - test('[1,2,3] is equal to [1,2,3]', () => { +test('[1,2,3] is equal to [1,2,3]', () => { expect(equals([1, 2, 3], [1, 2, 3])).toBeTruthy(); }); - test('{ a: [2, 3], b: [4] } is not equal to { a: [2, 3], b: [6] }', () => { +test('{ a: [2, 3], b: [4] } is not equal to { a: [2, 3], b: [6] }', () => { expect(equals({ a: [2, 3], b: [4] }, { a: [2, 3], b: [6] })).toBeFalsy(); }); - test('[1,2,3] is not equal to [1,2,4]', () => { +test('[1,2,3] is not equal to [1,2,4]', () => { expect(equals([1, 2, 3], [1, 2, 4])).toBeFalsy(); }); - test('[1, 2, 3] should be equal to { 0: 1, 1: 2, 2: 3 }) - type is different, but their enumerable properties match.', () => { +test('[1, 2, 3] should be equal to { 0: 1, 1: 2, 2: 3 }) - type is different, but their enumerable properties match.', () => { expect(equals([1, 2, 3], { 0: 1, 1: 2, 2: 3 })).toBeTruthy(); }); - - diff --git a/test/escapeHTML/escapeHTML.test.js b/test/escapeHTML/escapeHTML.test.js index 748a10562..26f1b0d9f 100644 --- a/test/escapeHTML/escapeHTML.test.js +++ b/test/escapeHTML/escapeHTML.test.js @@ -1,11 +1,9 @@ const expect = require('expect'); const escapeHTML = require('./escapeHTML.js'); - - test('escapeHTML is a Function', () => { +test('escapeHTML is a Function', () => { expect(escapeHTML).toBeInstanceOf(Function); }); - test('Escapes a string for use in HTML', () => { +test('Escapes a string for use in HTML', () => { expect(escapeHTML('Me & you')).toBe('<a href="#">Me & you</a>') -}); - +}); diff --git a/test/escapeRegExp/escapeRegExp.test.js b/test/escapeRegExp/escapeRegExp.test.js index 8483c0a88..0036bc296 100644 --- a/test/escapeRegExp/escapeRegExp.test.js +++ b/test/escapeRegExp/escapeRegExp.test.js @@ -1,11 +1,9 @@ const expect = require('expect'); const escapeRegExp = require('./escapeRegExp.js'); - - test('escapeRegExp is a Function', () => { +test('escapeRegExp is a Function', () => { expect(escapeRegExp).toBeInstanceOf(Function); }); - test('Escapes a string to use in a regular expression', () => { +test('Escapes a string to use in a regular expression', () => { expect(escapeRegExp('(test)')).toBe('\\(test\\)') -}); - +}); diff --git a/test/everyNth/everyNth.test.js b/test/everyNth/everyNth.test.js index 09918d3e0..b54958fc7 100644 --- a/test/everyNth/everyNth.test.js +++ b/test/everyNth/everyNth.test.js @@ -1,11 +1,9 @@ const expect = require('expect'); const everyNth = require('./everyNth.js'); - - test('everyNth is a Function', () => { +test('everyNth is a Function', () => { expect(everyNth).toBeInstanceOf(Function); }); - test('Returns every nth element in an array', () => { - expect(everyNth([1, 2, 3, 4, 5, 6], 2), [ 2, 4).toEqual(6 ]) +test('Returns every nth element in an array', () => { + expect(everyNth([1, 2, 3, 4, 5, 6], 2)).toEqual([ 2, 4, 6 ]); }); - diff --git a/test/extendHex/extendHex.test.js b/test/extendHex/extendHex.test.js index c196899e7..a31a3c6d2 100644 --- a/test/extendHex/extendHex.test.js +++ b/test/extendHex/extendHex.test.js @@ -1,14 +1,12 @@ const expect = require('expect'); const extendHex = require('./extendHex.js'); - - test('extendHex is a Function', () => { +test('extendHex is a Function', () => { expect(extendHex).toBeInstanceOf(Function); }); - test('Extends a 3-digit color code to a 6-digit color code', () => { - expect(extendHex('#03f')).toBe('#0033ff') +test('Extends a 3-digit color code to a 6-digit color code', () => { + expect(extendHex('#03f')).toBe('#0033ff'); }); - test('Extends a 3-digit color code to a 6-digit color code', () => { - expect(extendHex('05a')).toBe('#0055aa') +test('Extends a 3-digit color code to a 6-digit color code', () => { + expect(extendHex('05a')).toBe('#0055aa'); }); - diff --git a/test/factorial/factorial.test.js b/test/factorial/factorial.test.js index d13f79f2c..130d39a79 100644 --- a/test/factorial/factorial.test.js +++ b/test/factorial/factorial.test.js @@ -1,23 +1,21 @@ const expect = require('expect'); const factorial = require('./factorial.js'); - - test('factorial is a Function', () => { +test('factorial is a Function', () => { expect(factorial).toBeInstanceOf(Function); }); - test('Calculates the factorial of 720', () => { - expect(factorial(6)).toBe(720) +test('Calculates the factorial of 720', () => { + expect(factorial(6)).toBe(720); }); - test('Calculates the factorial of 0', () => { - expect(factorial(0)).toBe(1) +test('Calculates the factorial of 0', () => { + expect(factorial(0)).toBe(1); }); - test('Calculates the factorial of 1', () => { - expect(factorial(1)).toBe(1) +test('Calculates the factorial of 1', () => { + expect(factorial(1)).toBe(1); }); - test('Calculates the factorial of 4', () => { - expect(factorial(4)).toBe(24) +test('Calculates the factorial of 4', () => { + expect(factorial(4)).toBe(24); }); - test('Calculates the factorial of 10', () => { - expect(factorial(10)).toBe(3628800) +test('Calculates the factorial of 10', () => { + expect(factorial(10)).toBe(3628800); }); - diff --git a/test/factors/factors.test.js b/test/factors/factors.test.js index f25d0073a..961098ef4 100644 --- a/test/factors/factors.test.js +++ b/test/factors/factors.test.js @@ -1,8 +1,6 @@ const expect = require('expect'); const factors = require('./factors.js'); - - test('factors is a Function', () => { +test('factors is a Function', () => { expect(factors).toBeInstanceOf(Function); }); - diff --git a/test/fibonacci/fibonacci.test.js b/test/fibonacci/fibonacci.test.js index 5a44cba21..c13d3551b 100644 --- a/test/fibonacci/fibonacci.test.js +++ b/test/fibonacci/fibonacci.test.js @@ -1,11 +1,9 @@ const expect = require('expect'); const fibonacci = require('./fibonacci.js'); - - test('fibonacci is a Function', () => { +test('fibonacci is a Function', () => { expect(fibonacci).toBeInstanceOf(Function); }); - test('Generates an array, containing the Fibonacci sequence', () => { - expect(fibonacci(6), [0, 1, 1, 2, 3).toEqual(5]) +test('Generates an array, containing the Fibonacci sequence', () => { + expect(fibonacci(6)).toEqual([0, 1, 1, 2, 3, 5]); }); - diff --git a/test/fibonacciCountUntilNum/fibonacciCountUntilNum.test.js b/test/fibonacciCountUntilNum/fibonacciCountUntilNum.test.js index 015094d79..249b4ae48 100644 --- a/test/fibonacciCountUntilNum/fibonacciCountUntilNum.test.js +++ b/test/fibonacciCountUntilNum/fibonacciCountUntilNum.test.js @@ -1,8 +1,6 @@ const expect = require('expect'); const fibonacciCountUntilNum = require('./fibonacciCountUntilNum.js'); - - test('fibonacciCountUntilNum is a Function', () => { +test('fibonacciCountUntilNum is a Function', () => { expect(fibonacciCountUntilNum).toBeInstanceOf(Function); }); - diff --git a/test/fibonacciUntilNum/fibonacciUntilNum.test.js b/test/fibonacciUntilNum/fibonacciUntilNum.test.js index 7ad0c0649..a639afad4 100644 --- a/test/fibonacciUntilNum/fibonacciUntilNum.test.js +++ b/test/fibonacciUntilNum/fibonacciUntilNum.test.js @@ -1,8 +1,6 @@ const expect = require('expect'); const fibonacciUntilNum = require('./fibonacciUntilNum.js'); - - test('fibonacciUntilNum is a Function', () => { +test('fibonacciUntilNum is a Function', () => { expect(fibonacciUntilNum).toBeInstanceOf(Function); }); - diff --git a/test/filterNonUnique/filterNonUnique.test.js b/test/filterNonUnique/filterNonUnique.test.js index faa135e79..b4ab55867 100644 --- a/test/filterNonUnique/filterNonUnique.test.js +++ b/test/filterNonUnique/filterNonUnique.test.js @@ -1,11 +1,10 @@ const expect = require('expect'); const filterNonUnique = require('./filterNonUnique.js'); - - test('filterNonUnique is a Function', () => { +test('filterNonUnique is a Function', () => { expect(filterNonUnique).toBeInstanceOf(Function); }); - test('Filters out the non-unique values in an array', () => { - expect(filterNonUnique([1, 2, 2, 3, 4, 4, 5]), [1,3).toEqual(5]) +test('Filters out the non-unique values in an array', () => { + expect(filterNonUnique([1, 2, 2, 3, 4, 4, 5])).toEqual([1,3, 5]); }); diff --git a/test/findKey/findKey.test.js b/test/findKey/findKey.test.js index 44fe47811..ca8b397b0 100644 --- a/test/findKey/findKey.test.js +++ b/test/findKey/findKey.test.js @@ -1,17 +1,15 @@ const expect = require('expect'); const findKey = require('./findKey.js'); - - test('findKey is a Function', () => { +test('findKey is a Function', () => { expect(findKey).toBeInstanceOf(Function); }); - t.deepEqual(findKey( +test('Returns the appropriate key', () => { + expect(findKey( { barney: { age: 36, active: true }, fred: { age: 40, active: false }, pebbles: { age: 1, active: true } }, - o => o['active'] -), 'barney', 'Returns the appropriate key'); - - + o => o['active']).toBe('barney'); +}); diff --git a/test/findLast/findLast.test.js b/test/findLast/findLast.test.js index 3949b7eef..34fa06939 100644 --- a/test/findLast/findLast.test.js +++ b/test/findLast/findLast.test.js @@ -1,12 +1,9 @@ const expect = require('expect'); const findLast = require('./findLast.js'); - - test('findLast is a Function', () => { +test('findLast is a Function', () => { expect(findLast).toBeInstanceOf(Function); }); - test('Finds last element for which the given function returns true', () => { - expect(findLast([1, 2, 3, 4], n => n % 2 === 1), 3).toBe() +test('Finds last element for which the given function returns true', () => { + expect(findLast([1, 2, 3, 4], n => n % 2 === 1)).toBe(3); }); - - diff --git a/test/findLastIndex/findLastIndex.test.js b/test/findLastIndex/findLastIndex.test.js index 190e2cde8..6f438daf6 100644 --- a/test/findLastIndex/findLastIndex.test.js +++ b/test/findLastIndex/findLastIndex.test.js @@ -1,12 +1,9 @@ const expect = require('expect'); const findLastIndex = require('./findLastIndex.js'); - - test('findLastIndex is a Function', () => { +test('findLastIndex is a Function', () => { expect(findLastIndex).toBeInstanceOf(Function); }); - test('Finds last index for which the given function returns true', () => { - expect(findLastIndex([1, 2, 3, 4], n => n % 2 === 1), 2).toBe() +test('Finds last index for which the given function returns true', () => { + expect(findLastIndex([1, 2, 3, 4], n => n % 2 === 1)).toBe(2); }); - - diff --git a/test/findLastKey/findLastKey.test.js b/test/findLastKey/findLastKey.test.js index 3ab1dc4ce..5277755d3 100644 --- a/test/findLastKey/findLastKey.test.js +++ b/test/findLastKey/findLastKey.test.js @@ -1,17 +1,15 @@ const expect = require('expect'); const findLastKey = require('./findLastKey.js'); - - test('findLastKey is a Function', () => { +test('findLastKey is a Function', () => { expect(findLastKey).toBeInstanceOf(Function); }); - t.equal(findLastKey( +test('eturns the appropriate key', () => { + expect(findLastKey( { barney: { age: 36, active: true }, fred: { age: 40, active: false }, pebbles: { age: 1, active: true } }, - o => o['active'] -), 'pebbles', 'Returns the appropriate key'); - - + o => o['active']).toBe('pebbles'); +}); diff --git a/test/flatten/flatten.test.js b/test/flatten/flatten.test.js index a912af451..536a63637 100644 --- a/test/flatten/flatten.test.js +++ b/test/flatten/flatten.test.js @@ -1,14 +1,12 @@ const expect = require('expect'); const flatten = require('./flatten.js'); - - test('flatten is a Function', () => { +test('flatten is a Function', () => { expect(flatten).toBeInstanceOf(Function); }); - test('Flattens an array', () => { - expect(flatten([1, [2], 3, 4]), [1, 2, 3).toEqual(4]) +test('Flattens an array', () => { + expect(flatten([1, [2], 3, 4])).toEqual([1, 2, 3, 4]); }); - test('Flattens an array', () => { - expect(flatten([1, [2, [3, [4, 5], 6], 7], 8], 2), [1, 2, 3, [4, 5], 6, 7).toEqual(8]) +test('Flattens an array', () => { + expect(flatten([1, [2, [3, [4, 5], 6], 7], 8], 2)).toEqual([1, 2, 3, [4, 5], 6, 7, 8]); }); - diff --git a/test/flattenObject/flattenObject.test.js b/test/flattenObject/flattenObject.test.js index eb353fa5f..8ccafaf3e 100644 --- a/test/flattenObject/flattenObject.test.js +++ b/test/flattenObject/flattenObject.test.js @@ -1,15 +1,12 @@ const expect = require('expect'); const flattenObject = require('./flattenObject.js'); - - test('flattenObject is a Function', () => { +test('flattenObject is a Function', () => { expect(flattenObject).toBeInstanceOf(Function); }); - test('Flattens an object with the paths for keys', () => { - expect(flattenObject({ a: { b: { c: 1 } }, d: 1 }), { 'a.b.c': 1, d: 1 }).toEqual() +test('Flattens an object with the paths for keys', () => { + expect(flattenObject({ a: { b: { c: 1 } }, d: 1 })).toEqual({ 'a.b.c': 1, d: 1 }); }); - test('Works with arrays', () => { - expect(flattenObject([0,1,[2,[1]],1]), { 0: 0, 1: 1, 3: 1, '2.0': 2, '2.1.0': 1 }).toEqual() +test('Works with arrays', () => { + expect(flattenObject([0,1,[2,[1]],1])).toEqual({ 0: 0, 1: 1, 3: 1, '2.0': 2, '2.1.0': 1 }); }); - - diff --git a/test/flip/flip.test.js b/test/flip/flip.test.js index 912e91c22..26ad46f43 100644 --- a/test/flip/flip.test.js +++ b/test/flip/flip.test.js @@ -1,16 +1,13 @@ const expect = require('expect'); const flip = require('./flip.js'); - - test('flip is a Function', () => { +test('flip is a Function', () => { expect(flip).toBeInstanceOf(Function); }); - let a = { name: 'John Smith' }; - let b = {}; - const mergeFrom = flip(Object.assign); - let mergePerson = mergeFrom.bind(null, a); - test('Flips argument order', () => { - expect(mergePerson(b), a).toEqual() +let a = { name: 'John Smith' }; +let b = {}; +const mergeFrom = flip(Object.assign); +let mergePerson = mergeFrom.bind(null, a); +test('Flips argument order', () => { + expect(mergePerson(b)).toEqual(a); }); - - diff --git a/test/forEachRight/forEachRight.test.js b/test/forEachRight/forEachRight.test.js index bd42e32f3..75eabf617 100644 --- a/test/forEachRight/forEachRight.test.js +++ b/test/forEachRight/forEachRight.test.js @@ -1,14 +1,11 @@ const expect = require('expect'); const forEachRight = require('./forEachRight.js'); - - test('forEachRight is a Function', () => { +test('forEachRight is a Function', () => { expect(forEachRight).toBeInstanceOf(Function); }); - let output = ''; - forEachRight([1, 2, 3, 4], val => output+=val); - test('Iterates over the array in reverse', () => { - expect(output, '4321').toBe() +let output = ''; +forEachRight([1, 2, 3, 4], val => output+=val); +test('Iterates over the array in reverse', () => { + expect(output).toBe('4321') }); - - diff --git a/test/forOwn/forOwn.test.js b/test/forOwn/forOwn.test.js index 1b41dfb38..74c408c62 100644 --- a/test/forOwn/forOwn.test.js +++ b/test/forOwn/forOwn.test.js @@ -1,14 +1,11 @@ const expect = require('expect'); const forOwn = require('./forOwn.js'); - - test('forOwn is a Function', () => { +test('forOwn is a Function', () => { expect(forOwn).toBeInstanceOf(Function); }); - let output = []; - forOwn({ foo: 'bar', a: 1 }, v => output.push(v)); - test('Iterates over an element\'s key-value pairs', () => { - expect(output, ['bar', 1]).toEqual() +let output = []; +forOwn({ foo: 'bar', a: 1 }, v => output.push(v)); +test('Iterates over an element\'s key-value pairs', () => { + expect(output).toEqual(['bar', 1]); }); - - diff --git a/test/forOwnRight/forOwnRight.test.js b/test/forOwnRight/forOwnRight.test.js index 01ce32b65..781d287fe 100644 --- a/test/forOwnRight/forOwnRight.test.js +++ b/test/forOwnRight/forOwnRight.test.js @@ -1,14 +1,11 @@ const expect = require('expect'); const forOwnRight = require('./forOwnRight.js'); - - test('forOwnRight is a Function', () => { +test('forOwnRight is a Function', () => { expect(forOwnRight).toBeInstanceOf(Function); }); - let output = []; - forOwnRight({ foo: 'bar', a: 1 }, v => output.push(v)); - test('Iterates over an element\'s key-value pairs in reverse', () => { - expect(output, [1, 'bar']).toEqual() +let output = []; +forOwnRight({ foo: 'bar', a: 1 }, v => output.push(v)); +test('Iterates over an element\'s key-value pairs in reverse', () => { + expect(output).toEqual([1, 'bar']); }); - - diff --git a/test/formatDuration/formatDuration.test.js b/test/formatDuration/formatDuration.test.js index fbef44981..780ffae26 100644 --- a/test/formatDuration/formatDuration.test.js +++ b/test/formatDuration/formatDuration.test.js @@ -1,14 +1,12 @@ const expect = require('expect'); const formatDuration = require('./formatDuration.js'); - - test('formatDuration is a Function', () => { +test('formatDuration is a Function', () => { expect(formatDuration).toBeInstanceOf(Function); }); - test('Returns the human readable format of the given number of milliseconds', () => { - expect(formatDuration(1001), '1 second).toBe(1 millisecond') +test('Returns the human readable format of the given number of milliseconds', () => { + expect(formatDuration(1001)).toBe('1 second, 1 millisecond'); }); - test('Returns the human readable format of the given number of milliseconds', () => { - expect(formatDuration(34325055574), '397 days, 6 hours, 44 minutes, 15 seconds).toBe(574 milliseconds') +test('Returns the human readable format of the given number of milliseconds', () => { + expect(formatDuration(34325055574)).toBe('397 days, 6 hours, 44 minutes, 15 seconds, 574 milliseconds'); }); - diff --git a/test/fromCamelCase/fromCamelCase.test.js b/test/fromCamelCase/fromCamelCase.test.js index c20257ab1..5491058ac 100644 --- a/test/fromCamelCase/fromCamelCase.test.js +++ b/test/fromCamelCase/fromCamelCase.test.js @@ -1,17 +1,15 @@ const expect = require('expect'); const fromCamelCase = require('./fromCamelCase.js'); - - test('fromCamelCase is a Function', () => { +test('fromCamelCase is a Function', () => { expect(fromCamelCase).toBeInstanceOf(Function); }); - test('Converts a string from camelcase', () => { - expect(fromCamelCase('someDatabaseFieldName', ' ')).toBe('some database field name') +test('Converts a string from camelcase', () => { + expect(fromCamelCase('someDatabaseFieldName', ' ')).toBe('some database field name'); }); - test('Converts a string from camelcase', () => { - expect(fromCamelCase('someLabelThatNeedsToBeCamelized', '-')).toBe('some-label-that-needs-to-be-camelized') +test('Converts a string from camelcase', () => { + expect(fromCamelCase('someLabelThatNeedsToBeCamelized', '-')).toBe('some-label-that-needs-to-be-camelized'); }); - test('Converts a string from camelcase', () => { - expect(fromCamelCase('someJavascriptProperty', '_')).toBe('some_javascript_property') +test('Converts a string from camelcase', () => { + expect(fromCamelCase('someJavascriptProperty', '_')).toBe('some_javascript_property'); }); - diff --git a/test/functionName/functionName.test.js b/test/functionName/functionName.test.js index 750c856b1..a4255180e 100644 --- a/test/functionName/functionName.test.js +++ b/test/functionName/functionName.test.js @@ -4,22 +4,20 @@ const console = {}; console.debug = (x) => output = x; const functionName = fn => (console.debug(fn.name), fn); - test('functionName is a Function', () => { +test('functionName is a Function', () => { expect(functionName).toBeInstanceOf(Function); }); - functionName(Math.max); - test('Works for native functions', () => { - expect(output, 'max').toBe() +functionName(Math.max); +test('Works for native functions', () => { + expect(output).toBe('max'); }); - function fun(x) {return x;} - functionName(fun); - test('Works for functions', () => { - expect(output, 'fun').toBe() +function fun(x) {return x;} +functionName(fun); +test('Works for functions', () => { + expect(output).toBe('fun'); }); - const fn = x => x; - functionName(fn); - test('Works for arrow functions', () => { - expect(output, 'fn').toBe() +const fn = x => x; +functionName(fn); +test('Works for arrow functions', () => { + expect(output).toBe('fn'); }); - - diff --git a/test/functions/functions.test.js b/test/functions/functions.test.js index cade171cb..d8d8ad5fe 100644 --- a/test/functions/functions.test.js +++ b/test/functions/functions.test.js @@ -1,20 +1,17 @@ const expect = require('expect'); const functions = require('./functions.js'); - - test('functions is a Function', () => { +test('functions is a Function', () => { expect(functions).toBeInstanceOf(Function); }); - function Foo() { - this.a = () => 1; - this.b = () => 2; - } - Foo.prototype.c = () => 3; - test('Returns own methods', () => { - expect(functions(new Foo()), ['a', 'b']).toEqual() +function Foo() { + this.a = () => 1; + this.b = () => 2; +} +Foo.prototype.c = () => 3; +test('Returns own methods', () => { + expect(functions(new Foo()).toEqual( ['a', 'b']); }); - test('Returns own and inherited methods', () => { - expect(functions(new Foo(), true), ['a', 'b', 'c']).toEqual() +test('Returns own and inherited methods', () => { + expect(functions(new Foo(), true)).toEqual(['a', 'b', 'c']); }); - -