mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-04 07:29:47 +08:00
16 lines
504 B
JavaScript
16 lines
504 B
JavaScript
import { sumOfGeometricProgression } from '../SumOfGeometricProgression'
|
|
|
|
describe('Sum Of Geometric Progression', () => {
|
|
it('should return the sum of a finite GP', () => {
|
|
expect(sumOfGeometricProgression(100, 1.5, 4)).toBe(812.5)
|
|
})
|
|
|
|
it('should return the sum of an infinite GP', () => {
|
|
expect(sumOfGeometricProgression(2, 0.5, Infinity)).toBe(4)
|
|
})
|
|
|
|
it('should throw when series diverges', () => {
|
|
expect(() => sumOfGeometricProgression(1, 1, Infinity)).toThrowError()
|
|
})
|
|
})
|