32 lines
897 B
TypeScript
32 lines
897 B
TypeScript
import "../setup.ts";
|
|
import { assertEquals } from "@std/assert";
|
|
import { dumpApiToRow, type DumpRow, dumpRowToApi } from "../../model/dump.ts";
|
|
|
|
Deno.test("dump rows round-trip through the API shape", () => {
|
|
const row: DumpRow = {
|
|
id: "id",
|
|
kind: "url",
|
|
title: "t",
|
|
slug: "t-id",
|
|
comment: null,
|
|
user_id: "u",
|
|
created_at: "2024-01-01T00:00:00.000Z",
|
|
updated_at: null,
|
|
url: "https://x",
|
|
rich_content: JSON.stringify({ type: "generic", url: "https://x" }),
|
|
file_name: null,
|
|
file_mime: null,
|
|
file_size: null,
|
|
vote_count: 3,
|
|
comment_count: 2,
|
|
owner_username: "bob",
|
|
is_private: 1,
|
|
custom_thumbnail_mime: null,
|
|
};
|
|
const dump = dumpRowToApi(row);
|
|
assertEquals(dump.isPrivate, true);
|
|
assertEquals(dump.richContent?.url, "https://x");
|
|
assertEquals(dump.comment, undefined);
|
|
assertEquals(dumpApiToRow(dump), row);
|
|
});
|