Page MenuHomeSealhub

document.test.ts
No OneTemporary

document.test.ts

import { FileManager } from "@sealcode/file-manager";
import {
Component,
ComponentArgument,
JDDContext,
documentContainerFromParsed,
documentToStorage,
makeSimpleJDDContext,
} from "./index.js";
import { Registry } from "./registry.js";
import assert from "assert";
describe("document", () => {
it("converts from parsed to storage", async () => {
const registry = new Registry();
const args = {
test: new (class extends ComponentArgument<number, string, string> {
countWords() {
return 0;
}
getEmptyValue() {
return 0;
}
getSubArgument(): never {
throw new Error("no arguments");
}
getTypeName() {
return "test";
}
async storageToParsed(
_context: JDDContext,
value: string
): Promise<number> {
return parseInt(value);
}
async parsedToStorage(
_context: JDDContext,
value: number
): Promise<string> {
return value.toString();
}
async receivedToParsed(
_context: JDDContext,
value: string
): Promise<number> {
return parseInt(value);
}
})(),
};
registry.add(
"test",
class extends Component<typeof args> {
getArguments() {
return args;
}
toHTML() {
return "";
}
}
);
const document = documentContainerFromParsed([
{ component_name: "test", args: { test: 1 } },
{ component_name: "test", args: { test: 2 } },
]);
const to_store = await documentToStorage(
registry,
makeSimpleJDDContext(new FileManager("/tmp", "/uploaded_files")),
document
);
assert.deepStrictEqual(to_store.value, [
{ component_name: "test", args: { test: "1" } },
{ component_name: "test", args: { test: "2" } },
]);
});
});

File Metadata

Mime Type
text/x-java
Expires
Tue, Jul 8, 07:50 (17 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
801597
Default Alt Text
document.test.ts (1 KB)

Event Timeline