@octopusdeploy/design-system-components
Version:
The design systems component library.
30 lines (29 loc) • 1.35 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const vitest_1 = require("vitest");
const alphanumericSort_1 = require("../alphanumericSort");
(0, vitest_1.describe)("alphanumericSort", () => {
(0, vitest_1.it)("should sort strings alphabetically", () => {
const items = ["zebra", "apple", "banana"];
const result = (0, alphanumericSort_1.alphanumericSort)(items, (item) => item);
(0, vitest_1.expect)(result).toEqual(["apple", "banana", "zebra"]);
});
(0, vitest_1.it)("should sort numbers naturally within strings", () => {
const items = ["item10", "item2", "item1", "item20"];
const result = (0, alphanumericSort_1.alphanumericSort)(items, (item) => item);
(0, vitest_1.expect)(result).toEqual(["item1", "item2", "item10", "item20"]);
});
(0, vitest_1.it)("should sort objects by selected property", () => {
const items = [
{ name: "item10", value: 1 },
{ name: "item2", value: 2 },
{ name: "item1", value: 3 },
];
const result = (0, alphanumericSort_1.alphanumericSort)(items, (item) => item.name);
(0, vitest_1.expect)(result).toEqual([
{ name: "item1", value: 3 },
{ name: "item2", value: 2 },
{ name: "item10", value: 1 },
]);
});
});