Page MenuHomeSealhub

structured.test.ts
No OneTemporary

structured.test.ts

import { ExtractParsed } from "./component-argument.js";
import { List } from "./list.js";
import { ShortText } from "./short-text.js";
import { Structured } from "./structured.js";
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
});
});

File Metadata

Mime Type
text/x-java
Expires
Mon, May 19, 00:56 (1 d, 17 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
629197
Default Alt Text
structured.test.ts (1 KB)

Event Timeline