Skip to main content
This release is 23 versions behind 1.4.9 — the latest version of @fedify/fedify. Jump to latest

Built and signed on GitHub Actions

An ActivityPub/fediverse server framework

This package works with Node.js, Deno, Bun
This package works with Node.js
This package works with Deno
This package works with Bun
JSR Score
94%
Published
3 months ago (1.3.3)
Package root>codegen>class.test.ts
import { assertEquals } from "jsr:@std/assert@^0.226.0"; import { dirname, join } from "jsr:@std/path@^1.0.6"; import { assertSnapshot } from "jsr:/@std/testing@^0.224.0/snapshot"; import metadata from "../deno.json" with { type: "json" }; import { test } from "../testing/mod.ts"; import { generateClasses, sortTopologically } from "./class.ts"; import { loadSchemaFiles } from "./schema.ts"; test("sortTopologically()", () => { const sorted = sortTopologically({ "https://example.com/quux": { uri: "https://example.com/quux", name: "Foo", extends: "https://example.com/qux", entity: true, description: "", properties: [], defaultContext: {}, }, "https://example.com/qux": { uri: "https://example.com/qux", name: "Foo", extends: "https://example.com/bar", entity: true, description: "", properties: [], defaultContext: {}, }, "https://example.com/baz": { uri: "https://example.com/baz", name: "Foo", extends: "https://example.com/foo", entity: true, description: "", properties: [], defaultContext: {}, }, "https://example.com/bar": { uri: "https://example.com/bar", name: "Foo", extends: "https://example.com/foo", entity: true, description: "", properties: [], defaultContext: {}, }, "https://example.com/foo": { uri: "https://example.com/foo", name: "Foo", entity: true, description: "", properties: [], defaultContext: {}, }, }); assertEquals( sorted, [ "https://example.com/foo", "https://example.com/bar", "https://example.com/qux", "https://example.com/quux", "https://example.com/baz", ], ); }); test("generateClasses()", async (t) => { const schemaDir = join(dirname(import.meta.dirname!), "vocab"); const runtimePath = "../runtime/"; const types = await loadSchemaFiles(schemaDir); let entireCode = ""; for await (const code of generateClasses(types, runtimePath)) { entireCode += code; } entireCode = entireCode.replaceAll( JSON.stringify(metadata.version), '"0.0.0"', ); await assertSnapshot(t, entireCode); });