sorters.test.js 635 B

1234567891011121314151617181920212223
  1. /* @vitest-environment node */
  2. import { describe, it, expect } from "vitest";
  3. import {
  4. sortNumericStringsAsc,
  5. sortNumericStringsDesc,
  6. sortFilesByNameAsc,
  7. } from "./sorters";
  8. describe("lib/frontend/explorer/sorters", () => {
  9. it("sorts numeric strings asc/desc", () => {
  10. expect(sortNumericStringsAsc(["10", "2", "1"])).toEqual(["1", "2", "10"]);
  11. expect(sortNumericStringsDesc(["10", "2", "1"])).toEqual(["10", "2", "1"]);
  12. });
  13. it("sorts files by name asc", () => {
  14. const files = [{ name: "b.pdf" }, { name: "a.pdf" }];
  15. expect(sortFilesByNameAsc(files).map((f) => f.name)).toEqual([
  16. "a.pdf",
  17. "b.pdf",
  18. ]);
  19. });
  20. });