Skip to main content
Glama
by Ritesh-sudo
index.spec.ts2.12 kB
import { describe, it, expect } from "vitest"; import { parseDocument, parseDOM, createDocumentStream, createDomStream, DomHandler, DefaultHandler, type Parser, } from "./index.js"; import { Element } from "domhandler"; // Add an `attributes` prop to the Element for now, to make it possible for Jest to render DOM nodes. Object.defineProperty(Element.prototype, "attributes", { get() { return Object.keys(this.attribs).map((name) => ({ name, value: this.attribs[name], })); }, configurable: true, enumerable: false, }); describe("Index", () => { it("parseDocument", () => { const dom = parseDocument("<a foo><b><c><?foo>Yay!"); expect(dom).toMatchSnapshot(); }); it("parseDOM", () => { const dom = parseDOM("<a foo><b><c><?foo>Yay!"); expect(dom).toMatchSnapshot(); }); it("createDocumentStream", () => { let documentStream!: Parser; const documentPromise = new Promise( (resolve, reject) => (documentStream = createDocumentStream((error, dom) => error ? reject(error) : resolve(dom), )), ); for (const c of "&amp;This is text<!-- and comments --><tags>") { documentStream.write(c); } documentStream.end(); return expect(documentPromise).resolves.toMatchSnapshot(); }); it("createDomStream", () => { let domStream!: Parser; const domPromise = new Promise( (resolve, reject) => (domStream = createDomStream((error, dom) => error ? reject(error) : resolve(dom), )), ); for (const c of "&amp;This is text<!-- and comments --><tags>") { domStream.write(c); } domStream.end(); return expect(domPromise).resolves.toMatchSnapshot(); }); describe("API", () => { it("should export the appropriate APIs", () => { expect(DomHandler).toEqual(DefaultHandler); }); }); });

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/Ritesh-sudo/MCPJobSearch'

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