mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
27 lines
766 B
TypeScript
27 lines
766 B
TypeScript
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|||
|
|
|
||
|
|
const entries = vi.hoisted(() => ["z-last.png", "a-first.png", "m-middle.png"]);
|
||
|
|
|
||
|
|
vi.mock("node:fs", () => ({
|
||
|
|
existsSync: () => true,
|
||
|
|
readdirSync: () => [...entries],
|
||
|
|
}));
|
||
|
|
|
||
|
|
import { buildGeneratedFixtureIndex } from "../../helpers/generated-fixtures.js";
|
||
|
|
|
||
|
|
describe("generated fixture ordering", () => {
|
||
|
|
beforeEach(() => {
|
||
|
|
entries.splice(0, entries.length, "z-last.png", "a-first.png", "m-middle.png");
|
||
|
|
});
|
||
|
|
|
||
|
|
it("sorts filesystem discovery deterministically", () => {
|
||
|
|
const fixtures = buildGeneratedFixtureIndex(["/fixtures"]);
|
||
|
|
|
||
|
|
expect(fixtures.get(".png")?.map(({ filename }) => filename)).toEqual([
|
||
|
|
"a-first.png",
|
||
|
|
"m-middle.png",
|
||
|
|
"z-last.png",
|
||
|
|
]);
|
||
|
|
});
|
||
|
|
});
|