Skip to main content
Glama
by microsoft
markdown.test.ts3.71 kB
// cSpell: disable import { describe, test } from "node:test" import { MarkdownStringify, splitMarkdownTextImageParts } from "./markdown" import assert from "node:assert/strict" import { parseTraceTree } from "./traceparser" describe("trace tree", () => { test("empty", () => { const { root: res } = parseTraceTree(undefined) delete res.id assert.deepStrictEqual(res, { type: "details", label: "trace", content: [""], }) }) test("stringify", () => { assert.strictEqual(MarkdownStringify({ a: 1 }), "\n- a: 1\n") assert.strictEqual( MarkdownStringify({ a: 1, b: 2 }), "\n- a: 1\n- b: 2\n" ) assert.strictEqual( MarkdownStringify({ a: "string" }, { quoteValues: true }), "\n- a: `string`\n" ) assert.strictEqual(MarkdownStringify([1, 2, 3]), "\n- 1\n- 2\n- 3\n") assert.strictEqual( MarkdownStringify({ a: 1 }, { headings: 0, headingLevel: 3 }), "\n### A\n1\n" ) }) test("flat", () => { const { root: res } = parseTraceTree(` flat tree 2 3 `) delete res.id assert.deepStrictEqual(res, { type: "details", label: "trace", content: [ ` flat tree 2 3 `, ], }) }) test("one node", () => { const { root: res } = parseTraceTree(` flat tree <details> <summary>2</summary> 2.5 </details> 3 `) delete res.id delete (res.content[1] as any).id assert.deepStrictEqual(res, { type: "details", label: "trace", content: [ ` flat tree`, { type: "details", label: "2", content: ["2.5"] }, `3 `, ], }) }) test("multi node", () => { const { root: res } = parseTraceTree(` flat tree <details> <summary> 2 </summary> 2.5 </details> 3 `) delete res.id delete (res.content[1] as any).id assert.deepStrictEqual(res, { type: "details", label: "trace", content: [ ` flat tree`, { type: "details", label: "2", content: ["2.5"] }, `3 `, ], }) }) test("nested node", () => { const { root: res } = parseTraceTree(` flat tree <details> <summary> 2 </summary> <details> <summary> 2.5 </summary> 2.5.5 </details> </details> 3 `) delete res.id delete (res.content[1] as any).id delete (res.content[1] as any).content[0].id assert.deepStrictEqual(res, { type: "details", label: "trace", content: [ ` flat tree`, { type: "details", label: "2", content: [ { type: "details", label: "2.5", content: ["2.5.5"], }, ], }, `3 `, ], }) }) test("splitMarkdownTextImageParts - only text", async () => { const input = "This is a simple text block." const parts = await splitMarkdownTextImageParts(input) assert.deepStrictEqual(parts, [ { type: "text", text: "This is a simple text block." }, ]) }) test("splitMarkdownTextImageParts - empty string", async () => { const input = "" const parts = await splitMarkdownTextImageParts(input) assert.deepStrictEqual(parts, []) }) })

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/microsoft/genaiscript'

If you have feedback or need assistance with the MCP directory API, please join our Discord server