Skip to content
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"homepage": "https://github.com/MCRcodes/javascript-basics#readme",
"devDependencies": {
"eslint": "^6.5.1",
"eslint": "^8.3.0",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-config-prettier": "^6.4.0",
"eslint-plugin-import": "^2.18.2",
Expand Down
30 changes: 15 additions & 15 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,21 +72,21 @@ 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']);
});
});

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']);
});
});

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 @@ -96,7 +96,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 @@ -106,21 +106,21 @@ 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]);
});
});

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']);
});
});

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

xit('is case insensitive', () => {
it('is case insensitive', () => {
expect(
elementsStartingWithAVowel([
'Apple',
Expand Down Expand Up @@ -188,7 +188,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 Down
30 changes: 15 additions & 15 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 values are true', () => {
it('returns true if both of the given values 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 values are true', () => {
it('returns true if at least one of the given values 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 values are true', () => {
it('returns true if neither of the given values 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 values are true', () => {
it('returns true if exactly one of the given values 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 @@ -85,23 +85,23 @@ 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);
});
});

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);
});
});

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 @@ -110,7 +110,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 @@ -119,7 +119,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(5)).toEqual(false);
expect(isSquare(-4)).toEqual(false);
Expand All @@ -128,23 +128,23 @@ 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('a', 'qaardvark')).toBe(false);
expect(startsWith('a', 'Aardvark')).toBe(false);
});
});

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);
Expand Down
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