Skip to main content
Glama

Angular Bootstrap MCP Server

by palsuman
server.test.ts3.84 kB
import request from "supertest"; import express from "express"; import bodyParser from "body-parser"; import indexRoutes from "../routes/index"; import helpRoutes from "../routes/help"; import generateAppRoutes from "../routes/generateApp"; import generateArtifactRoutes from "../routes/generateArtifact"; import templatesRoutes from "../routes/templates"; const app = express(); app.use(bodyParser.json()); app.use("/", indexRoutes); app.use("/help", helpRoutes); app.use("/generate-angular-app", generateAppRoutes); app.use("/generate-artifact", generateArtifactRoutes); app.use("/templates", templatesRoutes); describe("MCP Server API", () => { it("GET / should return welcome message", async () => { const res = await request(app).get("/"); expect(res.statusCode).toBe(200); expect(res.text).toMatch(/Welcome to the MCP Server/i); }); it("GET /help should return help JSON", async () => { const res = await request(app).get("/help"); expect(res.statusCode).toBe(200); expect(res.body).toHaveProperty("message"); expect(res.body).toHaveProperty("usage"); }); it("GET /templates should return templates", async () => { const res = await request(app).get("/templates"); expect(res.statusCode).toBe(200); expect(res.body).toHaveProperty("categories"); expect(res.body).toHaveProperty("templates"); }); it("POST /generate-angular-app should fail without appName", async () => { const res = await request(app).post("/generate-angular-app").send({}); expect(res.statusCode).toBe(400); expect(res.body).toHaveProperty("error"); }); it("POST /generate-artifact should fail without required fields", async () => { const res = await request(app).post("/generate-artifact").send({}); expect(res.statusCode).toBe(400); expect(res.body).toHaveProperty("error"); }); it("POST /generate-artifact should fail with invalid type", async () => { const res = await request(app) .post("/generate-artifact") .send({ appName: "fakeApp", type: "invalidType", name: "test" }); expect(res.statusCode).toBe(400); expect(res.body).toHaveProperty("error"); expect(res.body.error).toMatch(/Invalid type/i); }); it("POST /generate-artifact should fail if app does not exist", async () => { const res = await request(app) .post("/generate-artifact") .send({ appName: "nonexistentApp", type: "component", name: "test" }); expect(res.statusCode).toBe(404); expect(res.body).toHaveProperty("error"); expect(res.body.error).toMatch(/App not found/i); }); it("POST /generate-artifact should accept a valid template name", async () => { // This will still fail if the app doesn't exist, but checks template param is accepted const res = await request(app) .post("/generate-artifact") .send({ appName: "nonexistentApp", type: "component", name: "test", template: "card" }); expect(res.statusCode).toBe(404); expect(res.body).toHaveProperty("error"); }); it("POST /generate-artifact should accept directory param", async () => { const res = await request(app) .post("/generate-artifact") .send({ appName: "nonexistentApp", type: "component", name: "test", directory: "shared/widgets" }); expect(res.statusCode).toBe(404); expect(res.body).toHaveProperty("error"); }); it("POST /generate-artifact should accept custom HTML", async () => { const res = await request(app) .post("/generate-artifact") .send({ appName: "nonexistentApp", type: "component", name: "test", html: "<div>Custom HTML</div>" }); expect(res.statusCode).toBe(404); expect(res.body).toHaveProperty("error"); }); // You can add more tests for successful artifact generation if you mock the file system and CLI. });

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/palsuman/angular-bootstrap-mcp-server'

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