Page MenuHomeSealhub

component.test.ts
No OneTemporary

component.test.ts

import assert from "assert";
import { Table } from "./component-arguments/table.js";
import { Component } from "./component.js";
import {
List,
ShortText,
Structured,
makeSimpleEnglishJDDContext,
makeSimpleJDDContext,
} from "./index.js";
import { FileManager } from "@sealcode/file-manager";
describe("component class", () => {
describe("getSubArgument", () => {
it("traverses argument path that includes a table", () => {
const args = {
table: new Table(
new Structured({ title: new ShortText() }),
new Structured({ tags: new List(new ShortText()) })
),
};
const component = new (class extends Component<typeof args> {
getArguments() {
return args;
}
toHTML() {
return "";
}
})();
const [arg, _, values] = component.getArgumentAtPath(
"table/rows/2/cells/0/tags".split("/"),
{
table: {
rows: [
{
type: "header",
header_content: { title: "hehe" },
},
{
type: "header",
header_content: { title: "hehe2" },
},
{
type: "row",
cells: [{ tags: ["tag1", "tag2"] }],
},
],
},
}
);
assert(arg instanceof List);
assert.deepStrictEqual(values, ["tag1", "tag2"]);
});
});
it("Doesn't fail if provided with unknown arguments", async () => {
const args = {
title: new ShortText(),
};
const component = new (class extends Component<typeof args> {
getArguments() {
return args;
}
toHTML() {
return "";
}
})();
await component.convertStorageToParsed(
makeSimpleEnglishJDDContext(new FileManager("/tmp", "/tmp")),
{ title2: "string" } as any
);
await component.convertParsedToStorage(
makeSimpleEnglishJDDContext(new FileManager("/tmp", "/tmp")),
{ title2: "string" } as any
);
});
});

File Metadata

Mime Type
text/x-java
Expires
Tue, Dec 24, 14:02 (17 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
557208
Default Alt Text
component.test.ts (1 KB)

Event Timeline