Additional tests

This commit is contained in:
Angelos Chalaris
2018-10-26 21:26:34 +03:00
parent 6090836233
commit 0ba22da4b0
4 changed files with 27 additions and 0 deletions

View File

@ -4,3 +4,6 @@ const {JSONToDate} = require('./_30s.js');
test('JSONToDate is a Function', () => {
expect(JSONToDate).toBeInstanceOf(Function);
});
test('JSONToDate returns the correct date string', () => {
expect(JSONToDate(/Date(1489525200000)/)).toBe("14/3/2017");
});

View File

@ -4,3 +4,9 @@ const {countVowels} = require('./_30s.js');
test('countVowels is a Function', () => {
expect(countVowels).toBeInstanceOf(Function);
});
test('countVowels returns the correct count', () => {
expect(countVowels('foobar')).toBe(3);
});
test('countVowels returns the correct count', () => {
expect(countVowels('ggg')).toBe(0);
});

View File

@ -4,3 +4,15 @@ const {factors} = require('./_30s.js');
test('factors is a Function', () => {
expect(factors).toBeInstanceOf(Function);
});
test('factors returns the correct array', () => {
expect(factors(12)).toEqual([2, 3, 4, 6, 12]);
});
test('factors returns the correct array of primes', () => {
expect(factors(12, true)).toEqual([2, 3]);
});
test('factors returns the correct array for negatives', () => {
expect(factors(-12)).toEqual([2, -2, 3, -3, 4, -4, 6, -6, 12, -12]);
});
test('factors returns the correct array of primes for negatives', () => {
expect(factors(-12, true)).toEqual([2, 3]);
});

View File

@ -4,3 +4,9 @@ const {zipWith} = require('./_30s.js');
test('zipWith is a Function', () => {
expect(zipWith).toBeInstanceOf(Function);
});
test('zipWith returns the correct results', () => {
expect(zipWith([1, 2], [10, 20], [100, 200], (a, b, c) => a + b + c)).toEqual([111, 222]);
});
test('zipWith returns the correct results if no function is passed', () => {
expect(zipWith([1, 2], [10, 20], [100, 200])).toEqual([[1, 10, 100], [2, 20, 200]]);
});