diff --git a/packages/ui/src/components/Pagination/helpers.test.ts b/packages/ui/src/components/Pagination/helpers.test.ts index d5e33ef08..ca52f8f37 100644 --- a/packages/ui/src/components/Pagination/helpers.test.ts +++ b/packages/ui/src/components/Pagination/helpers.test.ts @@ -2,9 +2,12 @@ import { describe, expect, it } from "vitest"; import { range } from "./helpers"; describe("Helpers / Range", () => { - it("should return the empty list, given start >= end", () => { + it("should return the empty list, given start > end", () => { expect(range(20, 10)).toEqual([]); - expect(range(10, 10)).toEqual([]); + }); + + it("should return a single-element list, given start === end", () => { + expect(range(10, 10)).toEqual([10]); }); it("should return every number from start to end, inclusive, given start < end", () => { diff --git a/packages/ui/src/components/Pagination/helpers.ts b/packages/ui/src/components/Pagination/helpers.ts index 54fc9441c..ae03c1b1e 100644 --- a/packages/ui/src/components/Pagination/helpers.ts +++ b/packages/ui/src/components/Pagination/helpers.ts @@ -2,15 +2,16 @@ * Generates an array of sequential numbers from a start value to an end value (inclusive). * @param start - The starting number of the range * @param end - The ending number of the range - * @returns An array of numbers from start to end. Returns empty array if start is greater than or equal to end. + * @returns An array of numbers from start to end. Returns empty array if start is greater than end. * @example * ```ts * range(1, 5) // returns [1, 2, 3, 4, 5] + * range(1, 1) // returns [1] * range(5, 1) // returns [] * ``` */ export function range(start: number, end: number): number[] { - if (start >= end) { + if (start > end) { return []; }