Skip to content
Open

Main #48

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .package.json.swo
Binary file not shown.
Binary file added .package.json.swp
Binary file not shown.
34 changes: 17 additions & 17 deletions src/__tests__/arrays.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,34 @@ const {
describe('getNthElement', () => {
const array = ['cat', 'dog', 'elephant', 'fox'];

xit('returns the element at the given position', () => {
it('returns the element at the given position', () => {
expect(getNthElement(0, array)).toEqual('cat');
expect(getNthElement(2, array)).toEqual('elephant');
expect(getNthElement(3, array)).toEqual('fox');
});

xit('if n is greater than the number of elements, it cycles back to the start', () => {
it('if n is greater than the number of elements, it cycles back to the start', () => {
expect(getNthElement(4, array)).toEqual('cat');
expect(getNthElement(5, array)).toEqual('dog');
});
});

describe('arrayToCSVString', () => {
xit('returns the array elements as a comma-seperated string', () => {
it('returns the array elements as a comma-seperated string', () => {
expect(arrayToCSVString(['a', 'b', 'c', 'd'])).toEqual('a,b,c,d');
expect(arrayToCSVString([1, 2, 3, 4, 5])).toEqual('1,2,3,4,5');
});
});

describe('csvStringToArray', () => {
xit('converts the csv string as an array', () => {
it('converts the csv string as an array', () => {
expect(csvStringToArray('a,b,c,d')).toEqual(['a', 'b', 'c', 'd']);
expect(csvStringToArray('1,2,3,4,5')).toEqual(['1', '2', '3', '4', '5']);
});
});

describe('addToArray', () => {
xit('adds the item to the end of the array', () => {
it('adds the item to the end of the array', () => {
const array = [];
const array2 = [1, 2, 3];

Expand All @@ -59,7 +59,7 @@ describe('addToArray', () => {
});

describe('addToArray2', () => {
xit('returns a new array with the value appended', () => {
it('returns a new array with the value appended', () => {
const array = ['a', 'b', 'c'];
const array2 = [1, 2, 3];

Expand All @@ -72,7 +72,7 @@ describe('addToArray2', () => {
});

describe('removeNthElement', () => {
xit('removes the element at position n', () => {
it('removes the element at position n', () => {
const array = ['ant', 'bison', 'cockerel', 'duck', 'elephant'];
removeNthElement(2, array);
expect(array).toEqual(['ant', 'bison', 'duck', 'elephant']);
Expand All @@ -84,14 +84,14 @@ describe('removeNthElement', () => {
});

describe('numbersToStrings', () => {
xit('converts every number in the array to a string', () => {
it('converts every number in the array to a string', () => {
expect(numbersToStrings([1, 2, 3])).toEqual(['1', '2', '3']);
expect(numbersToStrings([7, 8, 9])).toEqual(['7', '8', '9']);
});
});

describe('uppercaseWordsInArray', () => {
xit('makes every string in the array uppercase', () => {
it('makes every string in the array uppercase', () => {
expect(uppercaseWordsInArray(['cat', 'mouse', 'banana'])).toEqual([
'CAT',
'MOUSE',
Expand All @@ -106,7 +106,7 @@ describe('uppercaseWordsInArray', () => {
});

describe('reverseWordsInArray', () => {
xit('reverses every string in an array', () => {
it('reverses every string in an array', () => {
expect(reverseWordsInArray(['cat', 'Mouse', 'banana'])).toEqual([
'tac',
'esuoM',
Expand All @@ -121,14 +121,14 @@ describe('reverseWordsInArray', () => {
});

describe('onlyEven', () => {
xit('filters the array and only returns even numbers', () => {
it('filters the array and only returns even numbers', () => {
expect(onlyEven([1, 2, 3, 4, 5, 6, 7, 8])).toEqual([2, 4, 6, 8]);
expect(onlyEven([8, 9, 10, 11, 12, 13, 14, 15])).toEqual([8, 10, 12, 14]);
});
});

describe('removeNthElement2', () => {
xit('returns an array with the nth element removed, and does not mutate the original', () => {
it('returns an array with the nth element removed, and does not mutate the original', () => {
const array = ['bike', 'car', 'train', 'bus'];
expect(removeNthElement2(2, array)).toEqual(['bike', 'car', 'bus']);
expect(array).toEqual(['bike', 'car', 'train', 'bus']);
Expand All @@ -139,7 +139,7 @@ describe('removeNthElement2', () => {
});

describe('elementsStartingWithAVowel', () => {
xit('returns elements starting with a vowel', () => {
it('returns elements starting with a vowel', () => {
expect(
elementsStartingWithAVowel([
'apple',
Expand Down Expand Up @@ -179,7 +179,7 @@ describe('elementsStartingWithAVowel', () => {
).toEqual(['aaaa', 'eeee']);
});

xit('is case insensitive', () => {
it('is case insensitive', () => {
expect(
elementsStartingWithAVowel([
'Apple',
Expand Down Expand Up @@ -221,7 +221,7 @@ describe('elementsStartingWithAVowel', () => {
});

describe('removeSpaces', () => {
xit('returns the string with the space characters removed', () => {
it('returns the string with the space characters removed', () => {
expect(removeSpaces('this string has spaces')).toEqual(
'thisstringhasspaces'
);
Expand All @@ -232,14 +232,14 @@ describe('removeSpaces', () => {
});

describe('sumNumbers', () => {
xit('returns the sum of the numbers in the array', () => {
it('returns the sum of the numbers in the array', () => {
expect(sumNumbers([1, 3, 5, 6, 2, 8])).toEqual(25);
expect(sumNumbers([1, 3, 5])).toEqual(9);
});
});

describe('sortByLastLetter', () => {
xit('sorts the string by the last character', () => {
it('sorts the string by the last character', () => {
expect(
sortByLastLetter(['Lannister', 'Stark', 'Greyjoy', 'Targaryen'])
).toEqual(['Stark', 'Targaryen', 'Lannister', 'Greyjoy']);
Expand Down
32 changes: 16 additions & 16 deletions src/__tests__/booleans.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ const {
} = require('../booleans');

describe('negate', () => {
xit('returns the opposite of the passed boolean value', () => {
it('returns the opposite of the passed boolean value', () => {
expect(negate(true)).toBe(false);
expect(negate(false)).toBe(true);
});
});

describe('both', () => {
xit('returns true if both of the given booleans are true', () => {
it('returns true if both of the given booleans are true', () => {
expect(both(true, true)).toBe(true);
expect(both(true, false)).toBe(false);
expect(both(false, true)).toBe(false);
Expand All @@ -33,7 +33,7 @@ describe('both', () => {
});

describe('either', () => {
xit('returns true if at least one of the given booleans are true', () => {
it('returns true if at least one of the given booleans are true', () => {
expect(either(true, true)).toBe(true);
expect(either(true, false)).toBe(true);
expect(either(false, true)).toBe(true);
Expand All @@ -42,7 +42,7 @@ describe('either', () => {
});

describe('none', () => {
xit('returns true if neither of the given booleans are true', () => {
it('returns true if neither of the given booleans are true', () => {
expect(none(true, true)).toBe(false);
expect(none(true, false)).toBe(false);
expect(none(false, true)).toBe(false);
Expand All @@ -51,7 +51,7 @@ describe('none', () => {
});

describe('one', () => {
xit('returns true if exactly one of the given booleans are true', () => {
it('returns true if exactly one of the given booleans are true', () => {
expect(one(true, true)).toBe(false);
expect(one(true, false)).toBe(true);
expect(one(false, true)).toBe(true);
Expand All @@ -60,7 +60,7 @@ describe('one', () => {
});

describe('truthiness', () => {
xit('returns the truthiness of the given value', () => {
it('returns the truthiness of the given value', () => {
expect(truthiness('')).toBe(false);
expect(truthiness('dbbd')).toBe(true);
expect(truthiness(0)).toBe(false);
Expand All @@ -74,7 +74,7 @@ describe('truthiness', () => {
});

describe('isEqual', () => {
xit('returns whether the two values are equal', () => {
it('returns whether the two values are equal', () => {
expect(isEqual(true, false)).toBe(false);
expect(isEqual(true, true)).toBe(true);
expect(isEqual('true', 'true')).toBe(true);
Expand All @@ -86,7 +86,7 @@ describe('isEqual', () => {
});

describe('isGreaterThan', () => {
xit('returns true if the first number is strictly greater than the second', () => {
it('returns true if the first number is strictly greater than the second', () => {
expect(isGreaterThan(1, 2)).toBe(false);
expect(isGreaterThan(3, 2)).toBe(true);
expect(isGreaterThan(4, 4)).toBe(false);
Expand All @@ -98,7 +98,7 @@ describe('isGreaterThan', () => {
});

describe('isLessThanOrEqualTo', () => {
xit('returns true if the first number is less than or equal to the second', () => {
it('returns true if the first number is less than or equal to the second', () => {
expect(isLessThanOrEqualTo(1, 2)).toBe(true);
expect(isLessThanOrEqualTo(3, 2)).toBe(false);
expect(isLessThanOrEqualTo(4, 4)).toBe(true);
Expand All @@ -108,7 +108,7 @@ describe('isLessThanOrEqualTo', () => {
});

describe('isOdd', () => {
xit('returns whether the number is odd', () => {
it('returns whether the number is odd', () => {
expect(isOdd(5)).toBe(true);
expect(isOdd(6)).toBe(false);
expect(isOdd(7)).toBe(true);
Expand All @@ -117,7 +117,7 @@ describe('isOdd', () => {
});

describe('isEven', () => {
xit('returns whether the number is even', () => {
it('returns whether the number is even', () => {
expect(isEven(5)).toBe(false);
expect(isEven(6)).toBe(true);
expect(isEven(7)).toBe(false);
Expand All @@ -126,7 +126,7 @@ describe('isEven', () => {
});

describe('isSquare', () => {
xit('returns true if the number is a square', () => {
it('returns true if the number is a square', () => {
expect(isSquare(9)).toEqual(true);
expect(isSquare(4)).toEqual(true);
expect(isSquare(5)).toEqual(false);
Expand All @@ -136,7 +136,7 @@ describe('isSquare', () => {
});

describe('startsWith', () => {
xit('returns whether the given string starts with the given character', () => {
it('returns whether the given string starts with the given character', () => {
expect(startsWith('a', 'aardvark')).toBe(true);
expect(startsWith('c', 'aardvark')).toBe(false);
expect(startsWith('b', 'baardvark')).toBe(true);
Expand All @@ -146,17 +146,17 @@ describe('startsWith', () => {
});

describe('containsVowels', () => {
xit('returns whether the given string contains vowels', () => {
it('returns whether the given string contains vowels', () => {
expect(containsVowels('cat')).toBe(true);
expect(containsVowels('DOG')).toBe(true);
expect(containsVowels('why')).toBe(false);
});
});

describe('isLowerCase', () => {
xit('it returns true if the given string is lowercase', () => {
it('it returns true if the given string is lowercase', () => {
expect(isLowerCase('abc')).toBe(true);
expect(isLowerCase('abc213')).toBe(true);
expect(isLowerCase('Abc')).toBe(false);
});
});
});
22 changes: 11 additions & 11 deletions src/__tests__/numbers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const {
} = require('../numbers');

describe('add', () => {
xit('adds the two numbers together', () => {
it('adds the two numbers together', () => {
expect(add(2, 1)).toEqual(3);
expect(add(15, 76)).toEqual(91);
expect(add(12, 0)).toEqual(12);
Expand All @@ -22,7 +22,7 @@ describe('add', () => {
});

describe('subtract', () => {
xit('subtracts the second number from the first', () => {
it('subtracts the second number from the first', () => {
expect(subtract(2, 1)).toEqual(1);
expect(subtract(1, 2)).toEqual(-1);
expect(subtract(-2, 1)).toEqual(-3);
Expand All @@ -32,15 +32,15 @@ describe('subtract', () => {
});

describe('multiply', () => {
xit('multiplies the two numbers together', () => {
it('multiplies the two numbers together', () => {
expect(multiply(10, 3)).toEqual(30);
expect(multiply(-11, 5)).toEqual(-55);
expect(multiply(-4, -9)).toEqual(36);
});
});

describe('divide', () => {
xit('divides the first number by the second number', () => {
it('divides the first number by the second number', () => {
expect(divide(20, 5)).toEqual(4);
expect(divide(5, 2)).toEqual(2.5);
expect(divide(2, 5)).toEqual(0.4);
Expand All @@ -49,39 +49,39 @@ describe('divide', () => {
});

describe('power', () => {
xit('returns the first number to the power of the second', () => {
it('returns the first number to the power of the second', () => {
expect(power(5, 2)).toEqual(25);
expect(power(2, 3)).toEqual(8);
expect(power(10, 5)).toEqual(100000);
});
});

describe('round', () => {
xit('rounds the number to the nearest integer', () => {
it('rounds the number to the nearest integer', () => {
expect(round(2.1)).toEqual(2);
expect(round(9.7)).toEqual(10);
expect(round(5.5)).toEqual(6);
});
});

describe('roundUp', () => {
xit('rounds the number up to the nearest integer', () => {
it('rounds the number up to the nearest integer', () => {
expect(roundUp(2.1)).toEqual(3);
expect(roundUp(9.7)).toEqual(10);
expect(roundUp(5.5)).toEqual(6);
});
});

describe('roundDown', () => {
xit('rounds the number down to the nearest integer', () => {
it('rounds the number down to the nearest integer', () => {
expect(roundDown(2.1)).toEqual(2);
expect(roundDown(9.7)).toEqual(9);
expect(roundDown(5.5)).toEqual(5);
});
});

describe('absolute', () => {
xit('returns the absolute value of the number', () => {
it('returns the absolute value of the number', () => {
expect(absolute(-1)).toEqual(1);
expect(absolute(1)).toEqual(1);
expect(absolute(0)).toEqual(0);
Expand All @@ -93,7 +93,7 @@ describe('quotient', () => {
// the first by the second, without the remainder
// 18 divided by 7 is 2 remainder 4 (or 2.571...)
// so the quotient of 18 and 7 is 2
xit('returns the quotient from dividing the first number by the second number', () => {
it('returns the quotient from dividing the first number by the second number', () => {
expect(quotient(10, 3)).toEqual(3);
expect(quotient(18, 7)).toEqual(2);
expect(quotient(77, 10)).toEqual(7);
Expand All @@ -102,7 +102,7 @@ describe('quotient', () => {
});

describe('remainder', () => {
xit('returns the remainder when dividing the first number by the second number', () => {
it('returns the remainder when dividing the first number by the second number', () => {
expect(remainder(10, 3)).toEqual(1);
expect(remainder(18, 7)).toEqual(4);
expect(remainder(77, 10)).toEqual(7);
Expand Down
Loading