/* @vitest-environment node */

import { describe, it, expect } from "vitest";
import {
	sortNumericStringsAsc,
	sortNumericStringsDesc,
	sortFilesByNameAsc,
} from "./sorters";

describe("lib/frontend/explorer/sorters", () => {
	it("sorts numeric strings asc/desc", () => {
		expect(sortNumericStringsAsc(["10", "2", "1"])).toEqual(["1", "2", "10"]);
		expect(sortNumericStringsDesc(["10", "2", "1"])).toEqual(["10", "2", "1"]);
	});

	it("sorts files by name asc", () => {
		const files = [{ name: "b.pdf" }, { name: "a.pdf" }];
		expect(sortFilesByNameAsc(files).map((f) => f.name)).toEqual([
			"a.pdf",
			"b.pdf",
		]);
	});
});
