From 290fb3fe132186df69818e6a00b53412bcefef75 Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Wed, 31 Oct 2018 20:41:38 +0200 Subject: [PATCH] Additional tests --- test/factorial.test.js | 5 +++++ test/formatDuration.test.js | 3 +++ test/fromCamelCase.test.js | 2 +- test/getType.test.js | 6 ++++++ test/removeVowels.test.js | 6 ++++++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/test/factorial.test.js b/test/factorial.test.js index 5f3c8d963..413d0d150 100644 --- a/test/factorial.test.js +++ b/test/factorial.test.js @@ -19,3 +19,8 @@ test('Calculates the factorial of 4', () => { test('Calculates the factorial of 10', () => { expect(factorial(10)).toBe(3628800); }); +test('Throws TypeError if n < 0', () => { + expect(() => { + factorial(-1); + }).toThrow(TypeError); +}); diff --git a/test/formatDuration.test.js b/test/formatDuration.test.js index 078c048bf..2d64cb043 100644 --- a/test/formatDuration.test.js +++ b/test/formatDuration.test.js @@ -7,6 +7,9 @@ test('formatDuration is a Function', () => { 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 (negative)', () => { + expect(formatDuration(-1001)).toBe('1 second, 1 millisecond'); +}); 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.test.js b/test/fromCamelCase.test.js index c4fed066f..2c6b48db3 100644 --- a/test/fromCamelCase.test.js +++ b/test/fromCamelCase.test.js @@ -13,5 +13,5 @@ test('Converts a string from camelcase', () => { ); }); test('Converts a string from camelcase', () => { - expect(fromCamelCase('someJavascriptProperty', '_')).toBe('some_javascript_property'); + expect(fromCamelCase('someJavascriptProperty')).toBe('some_javascript_property'); }); diff --git a/test/getType.test.js b/test/getType.test.js index c402a0a16..38fda0470 100644 --- a/test/getType.test.js +++ b/test/getType.test.js @@ -7,3 +7,9 @@ test('getType is a Function', () => { test('Returns the native type of a value', () => { expect(getType(new Set([1, 2, 3]))).toBe('set'); }); +test('Returns null for null', () => { + expect(getType(null)).toBe('null'); +}); +test('Returns undefined for undefined', () => { + expect(getType(undefined)).toBe('undefined'); +}); diff --git a/test/removeVowels.test.js b/test/removeVowels.test.js index 13477fcb1..2243e2e02 100644 --- a/test/removeVowels.test.js +++ b/test/removeVowels.test.js @@ -4,3 +4,9 @@ const {removeVowels} = require('./_30s.js'); test('removeVowels is a Function', () => { expect(removeVowels).toBeInstanceOf(Function); }); +test('Removes vowels.', () => { + expect(removeVowels('foobAr')).toBe('fbr'); +}); +test('Replaces vowels.', () => { + expect(removeVowels('foobAr', '*')).toBe('f**b*r'); +});