Skip to content
Source
Sign inSign up
fuko/trytanstackdb.com
Open History to see the last commit

fixtures.test.ts

20 lines939 Bytes

1import { expect, test } from "vite-plus/test";
2​
3import { createSeedData, FIXTURES_WRITTEN_AT } from "./index";
4​
5test("fixtures parse and reference existing folders", () => {
6 const { folders, notes } = createSeedData();
7 const folderIds = new Set(folders.map((folder) => folder.id));
8 expect(notes.length).toBeGreaterThanOrEqual(20);
9 expect(notes.length).toBeLessThanOrEqual(40);
10 for (const note of notes) expect(folderIds.has(note.folderId)).toBe(true);
11 expect(new Set(notes.map((note) => note.id)).size).toBe(notes.length);
12});
13​
14test("seed timestamps are shifted relative to now", () => {
15 const now = new Date(Date.parse(FIXTURES_WRITTEN_AT) + 7 * 24 * 60 * 60 * 1000);
16 const shifted = createSeedData(now);
17 const original = createSeedData(new Date(FIXTURES_WRITTEN_AT));
18 const delta = Date.parse(shifted.notes[0]!.updatedAt) - Date.parse(original.notes[0]!.updatedAt);
19 expect(delta).toBe(7 * 24 * 60 * 60 * 1000);
20});