snapshot.test.js
831 bytes
| 1 | import { afterEach, describe, expect, it } from "vitest"; |
|---|---|
| 2 | import { createShare, makeHarness } from "./helpers.js"; |
| 3 | |
| 4 | describe("snapshot", () => { |
| 5 | let harness; |
| 6 | afterEach(() => harness.close()); |
| 7 | |
| 8 | it("stores only selected repositories and serves their frozen content", async () => { |
| 9 | harness = makeHarness(); |
| 10 | const { id } = await createShare(harness, [202]); |
| 11 | expect(harness.calls.snapshots).toEqual([[202]]); |
| 12 | expect(harness.calls.viewerReads).toBe(2); |
| 13 | const row = harness.store.getShare(id); |
| 14 | expect(row.snapshot.repositories.map((repo) => repo.name)).toEqual(["ledger"]); |
| 15 | expect(row.snapshot.profile.bio).toBe("Building useful software."); |
| 16 | row.snapshot.repositories[0].name = "changed outside storage"; |
| 17 | expect(harness.store.getShare(id).snapshot.repositories[0].name).toBe("ledger"); |
| 18 | }); |
| 19 | }); |
| 20 | |