added throwing an error when array with <3 items is passed

This commit is contained in:
devcer
2021-10-15 21:49:29 +05:30
parent b3377bb79c
commit 67ec915d97
2 changed files with 5 additions and 3 deletions

View File

@ -1,8 +1,10 @@
import { maxProductOfThree } from '../MaxProductOfThree'
describe('MaxProductOfThree', () => {
it('expects to return -1 for array with only 2 numbers', () => {
expect(maxProductOfThree([1, 3])).toBe(-1)
it('expects to throw error for array with only 2 numbers', () => {
expect(() => {
maxProductOfThree([1, 3])
}).toThrow('Triplet cannot exist with the given array')
})
it('expects to return 300 as the maximum product', () => {