Skip to main content
Glama
zbkm
by zbkm
search.test.ts1.52 kB
import { expect, test } from "bun:test"; import { searchMamont } from "../../src/mmnt/search.ts"; import { mockFetch } from "../mocks/fetch.ts"; import { spyFetch } from "./setupFetchSpy.ts"; test("search", async () => { const htmlBuffer = await Bun.file("./tests/mmnt/fixtures/search-1-page.html").arrayBuffer(); const expectedJson = await Bun.file("./tests/mmnt/fixtures/search-1-page-result.json").json(); spyFetch.mockImplementation(mockFetch(htmlBuffer)); const data = await searchMamont("mmnt"); expect(spyFetch).toHaveBeenCalledWith("https://www.mmnt.ru/get?st=mmnt&in=w&ot=1"); expect(data).toEqual(expectedJson); }); test("search with page", async () => { const htmlBuffer = await Bun.file("./tests/mmnt/fixtures/search-4-page.html").arrayBuffer(); const expectedJson = await Bun.file("./tests/mmnt/fixtures/search-4-page-result.json").json(); spyFetch.mockImplementation(mockFetch(htmlBuffer)); const data = await searchMamont("mmnt", 4); expect(spyFetch).toHaveBeenCalledWith("https://www.mmnt.ru/get?st=mmnt&in=w&ot=41"); expect(data).toEqual(expectedJson); }); test("search no result", async () => { const htmlBuffer = await Bun.file("./tests/mmnt/fixtures/search-no-result.html").arrayBuffer(); spyFetch.mockImplementation(mockFetch(htmlBuffer)); const data = await searchMamont("34t3hgrdhbdfnbdfgb"); expect(spyFetch).toHaveBeenCalledWith("https://www.mmnt.ru/get?st=34t3hgrdhbdfnbdfgb&in=w&ot=1"); expect(data).toBeEmpty(); });

Latest Blog Posts

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/zbkm/mmnt-mcp-server'

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