Initial commit
This commit is contained in:
19
turbo/generators/lib/snapshot.test.ts
Normal file
19
turbo/generators/lib/snapshot.test.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { mkdtempSync, mkdirSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { computeSnapshot } from "./snapshot.js";
|
||||
|
||||
describe("computeSnapshot", () => {
|
||||
it("returns sorted file paths + sha256 hashes", () => {
|
||||
const tmp = mkdtempSync(join(tmpdir(), "snapshot-"));
|
||||
mkdirSync(join(tmp, "src"));
|
||||
writeFileSync(join(tmp, "package.json"), `{ "name": "x" }\n`);
|
||||
writeFileSync(join(tmp, "src", "index.ts"), `export {};\n`);
|
||||
const snap = computeSnapshot(tmp);
|
||||
expect(snap).toEqual([
|
||||
{ path: "package.json", sha256: expect.any(String) },
|
||||
{ path: "src/index.ts", sha256: expect.any(String) },
|
||||
]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user