Files
JavaScript/Dynamic-Programming/tests/FibonacciNumber.test.js
Fahim Faisaal 8bf29fe17c merge: Optimize the space complexity of the fibonacci algo (#899)
* docs: update js doc

* feat: add number type validation condition

* pref: Optimize space complexity

remove the Array from the algo and used two flag varible to calculate last two numbers & optimize the sapce complexity O(n) to O(1)

* test: add test case for invalid types
2022-02-22 16:20:46 +05:30

26 lines
576 B
JavaScript

import { fibonacci } from '../FibonacciNumber'
describe('Testing FibonacciNumber', () => {
it('Testing for invalid type', () => {
expect(() => fibonacci('0')).toThrowError()
expect(() => fibonacci('12')).toThrowError()
expect(() => fibonacci(true)).toThrowError()
})
it('fibonacci of 0', () => {
expect(fibonacci(0)).toBe(0)
})
it('fibonacci of 1', () => {
expect(fibonacci(1)).toBe(1)
})
it('fibonacci of 10', () => {
expect(fibonacci(10)).toBe(55)
})
it('fibonacci of 25', () => {
expect(fibonacci(25)).toBe(75025)
})
})