diff --git a/test/index.test.js b/test/index.test.js index 97078cf..2da23cf 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -1,6 +1,6 @@ import assert from 'node:assert'; import { describe, it } from 'node:test'; -import { average, sort, sum } from '../src/index.js'; +import { average, median, sort, sum } from '../src/index.js'; describe('sum', () => { it('should sum all numbers', () => { @@ -25,6 +25,16 @@ describe('average', () => { }); }); +describe('median', () => { + it('should calculate median for odd-length array', () => { + assert.strictEqual(median([3, 1, 2]), 2); + }); + + it('should calculate median for even-length array', () => { + assert.strictEqual(median([3, 4, 1, 2]), 2.5); + }); +}); + describe('sort', () => { it('should sort numbers in ascending order by default', () => { assert.deepEqual(sort([4, 2, 1, 3]), [1, 2, 3, 4]);