queue/source/migrations/migrations.test.ts

30 lines
763 B
TypeScript

import {setup} from "@holllo/test";
import {dataMigrations, type QueueItemPre030} from "./migrations.js";
import snapshots from "./snapshots.json";
const queueItemSample: QueueItemPre030 = {
added: new Date("2022-03-02T16:00:00Z"),
id: 1,
text: "Sample",
url: "https://example.org",
};
await setup("Migrations", async (group) => {
group.test("Snapshots", async (test) => {
let data: Record<string, any> = {
latestVersion: "0.1.0",
queue: [queueItemSample],
};
for (const [index, migration] of dataMigrations.entries()) {
data = (await migration.migrate(data)) as Record<string, any>;
test.equals(
JSON.stringify(data, null, 2),
JSON.stringify(snapshots[index], null, 2),
);
}
});
});