Add archive snippet tests

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

View File

@ -4,3 +4,6 @@ const {fibonacciCountUntilNum} = require('./_30s.js');
test('fibonacciCountUntilNum is a Function', () => { test('fibonacciCountUntilNum is a Function', () => {
expect(fibonacciCountUntilNum).toBeInstanceOf(Function); expect(fibonacciCountUntilNum).toBeInstanceOf(Function);
}); });
test('Returns the correct number', () => {
expect(fibonacciCountUntilNum(10)).toBe(7);
});

View File

@ -4,3 +4,6 @@ const {fibonacciUntilNum} = require('./_30s.js');
test('fibonacciUntilNum is a Function', () => { test('fibonacciUntilNum is a Function', () => {
expect(fibonacciUntilNum).toBeInstanceOf(Function); expect(fibonacciUntilNum).toBeInstanceOf(Function);
}); });
test('Returns the correct sequence', () => {
expect(fibonacciUntilNum(10)).toEqual([0, 1, 1, 2, 3, 5, 8]);
});

View File

@ -4,3 +4,6 @@ const {heronArea} = require('./_30s.js');
test('heronArea is a Function', () => { test('heronArea is a Function', () => {
expect(heronArea).toBeInstanceOf(Function); expect(heronArea).toBeInstanceOf(Function);
}); });
test('howManyTimes returns the correct result', () => {
expect(heronArea(3, 4, 5)).toBe(6);
});

View File

@ -4,3 +4,15 @@ const {howManyTimes} = require('./_30s.js');
test('howManyTimes is a Function', () => { test('howManyTimes is a Function', () => {
expect(howManyTimes).toBeInstanceOf(Function); expect(howManyTimes).toBeInstanceOf(Function);
}); });
test('howManyTimes returns the correct result', () => {
expect(howManyTimes(100, 2)).toBe(2);
});
test('howManyTimes returns the correct result', () => {
expect(howManyTimes(100, 2.5)).toBe(2);
});
test('howManyTimes returns the correct result', () => {
expect(howManyTimes(100, 0)).toBe(0);
});
test('howManyTimes returns the correct result', () => {
expect(howManyTimes(100, -1)).toBe(Infinity);
});