Page MenuHomeSealhub

structured.test.ts
No OneTemporary

structured.test.ts

import { FileManager } from "@sealcode/file-manager";
import { makeSimpleEnglishJDDContext } from "../jdd-context.js";
import { ExtractParsed } from "./component-argument.js";
import { List } from "./list.js";
import { ShortText } from "./short-text.js";
import { Structured } from "./structured.js";
import assert from "assert";
describe("structured argument", () => {
it("properly extracts parsed type", () => {
const args = new Structured({
value: new ShortText().setExampleValues([""]),
tags: new List(new ShortText()).setExampleValues([["okazja"]]),
});
const values = {
value: "test",
tags: ["tag1", "tag2"],
} as ExtractParsed<typeof args>;
values.tags.map((tag) => tag.padStart(10)); // if the types are OK, this will typecheck OK
});
it("properly extracts parsed type within a list", () => {
const arg = new List(
new Structured({
value: new ShortText().setExampleValues([""]),
tags: new List(new ShortText()).setExampleValues([["okazja"]]),
})
);
const values = [
{
value: "test",
tags: ["tag1", "tag2"],
},
] as ExtractParsed<typeof arg>;
values[0].tags.map((tag) => tag.padStart(10)); // if the types are OK, this will typecheck OK
});
it("uses the provided object as an example value if set", async () => {
const arg = new Structured({
value: new ShortText().setExampleValues([""]),
tags: new List(new ShortText()).setExampleValues([["okazja"]]),
}).setExampleValues([{ value: "override", tags: ["override"] }]);
const example_value = await arg.getExampleValue(
makeSimpleEnglishJDDContext(
new FileManager("/tmp", "/uploaded_files")
)
);
assert.deepStrictEqual(example_value, {
value: "override",
tags: ["override"],
});
});
});

File Metadata

Mime Type
text/x-java
Expires
Fri, Jan 24, 15:16 (17 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
601028
Default Alt Text
structured.test.ts (1 KB)

Event Timeline