UNPKG

@qntm-code/utils

Version:

A collection of useful utility functions with associated TypeScript types. All functions have been unit tested.

18 lines (17 loc) 725 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const average_1 = require("./average"); describe('average', () => { it('should return the average of the given values', () => { expect((0, average_1.average)([1, 2, 3])).toBe(2); }); it('should throw an error when given an empty array', () => { expect(() => (0, average_1.average)([])).toThrow(new Error('Cannot calculate average of an empty array')); }); it('should handle negative numbers', () => { expect((0, average_1.average)([-1, -2, -3])).toBe(-2); }); it('should handle mixed positive and negative numbers', () => { expect((0, average_1.average)([-1, 0, 1])).toBe(0); }); });