Skip to main content
Glama

MCP Printer Server

by steveclarke
utils.test.ts2.78 kB
/** * @fileoverview Unit tests for pure utility functions */ import { describe, it, expect } from "vitest" import { parseDelimitedString, formatPrintResponse } from "../../src/utils.js" describe("parseDelimitedString", () => { it("should parse colon-delimited string", () => { const result = parseDelimitedString("foo:bar:baz", ":") expect(result).toEqual(["foo", "bar", "baz"]) }) it("should parse comma-delimited string", () => { const result = parseDelimitedString("a,b,c", ",") expect(result).toEqual(["a", "b", "c"]) }) it("should parse space-delimited string with regex", () => { const result = parseDelimitedString("opt1 opt2 opt3", /\s+/) expect(result).toEqual(["opt1", "opt2", "opt3"]) }) it("should trim whitespace and filter empty strings", () => { expect(parseDelimitedString(" foo : bar : baz ", ":")).toEqual(["foo", "bar", "baz"]) expect(parseDelimitedString("foo::bar", ":")).toEqual(["foo", "bar"]) expect(parseDelimitedString("foo, ,bar", ",")).toEqual(["foo", "bar"]) expect(parseDelimitedString("", ":")).toEqual([]) expect(parseDelimitedString(undefined, ":")).toEqual([]) }) it("should apply transform function", () => { const result = parseDelimitedString("FOO,Bar,BAZ", ",", (s) => s.toLowerCase()) expect(result).toEqual(["foo", "bar", "baz"]) }) it("should handle single item", () => { const result = parseDelimitedString("single", ":") expect(result).toEqual(["single"]) }) }) describe("formatPrintResponse", () => { it("should format basic response without options", () => { const result = formatPrintResponse("TestPrinter", 1, [], "/path/to/file.txt") expect(result.content).toHaveLength(1) expect(result.content[0].type).toBe("text") expect(result.content[0].text).toContain("TestPrinter") expect(result.content[0].text).toContain("Copies: 1") expect(result.content[0].text).toContain("/path/to/file.txt") expect(result.content[0].text).not.toContain("Options:") }) it("should format response with options and multiple copies", () => { const result = formatPrintResponse( "TestPrinter", 3, ["landscape", "sides=two-sided-long-edge"], "/path/to/file.pdf" ) expect(result.content[0].text).toContain("TestPrinter") expect(result.content[0].text).toContain("Copies: 3") expect(result.content[0].text).toContain("Options: landscape, sides=two-sided-long-edge") expect(result.content[0].text).toContain("/path/to/file.pdf") }) it("should include render type when provided", () => { const result = formatPrintResponse("TestPrinter", 1, [], "/path/to/file.md", "markdown → PDF") expect(result.content[0].text).toContain("Rendered: markdown → PDF") }) })

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/steveclarke/mcp-printer'

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