import {expect} from "chai" import { getRecomendElements } from "../../lib/getRecomended"; describe('getRecomendElements', function() { it('should return an empty array when the input array is empty', function() { const result = getRecomendElements([], 3); expect(result).to.be.an('array'); expect(result.length).to.be.equal(0); }); it('should throw an error when the input array is of incorrect type', function() { expect(() => getRecomendElements('not_an_array', 3)).to.have.length(0); }); it('should return an empty array if there are no items with prices within the range of 20 to max price', function() { const inputArray = [ { name: 'item1', price: 10 }, { name: 'item2', price: 15 }, ]; const result = getRecomendElements(inputArray, 3); expect(result).to.be.an('array'); expect(result.length).to.be.equal(2); }); it('should return the correct number of elements if not found in range 20/80% of max price', function() { const inputArray = [ { name: 'item1', price: 10 }, { name: 'item2', price: 25 }, { name: 'item3', price: 30 }, { name: 'item4', price: 15 }, { name: 'item4', price: 151 }, { name: 'item4', price: 103 }, { name: 'item4', price: 406 }, { name: 'item4', price: 9909 }, { name: 'item4', price: 10002 }, ]; const result = getRecomendElements(inputArray, 3); expect(result).to.be.an('array'); expect(result).to.have.length(3); }); it('should return the correct number of elements with a total price not exceeding the max price', function() { const inputArray = [ { name: 'item1', price: 10 }, { name: 'item2', price: 25 }, { name: 'item3', price: 5530 }, { name: 'item4', price: 15 }, { name: 'item4', price: 3151 }, { name: 'item4', price: 103 }, { name: 'item4', price: 2406 }, { name: 'item4', price: 9909 }, { name: 'item4', price: 10002 }, ]; const result = getRecomendElements(inputArray, 3); expect(result).to.be.an('array'); expect(result).to.have.length(3); }); // Add additional tests as needed });