Eventbrite MCP Server
by ibraheem4
- src
- __tests__
import { jest } from "@jest/globals";
// Mock environment variables
process.env.EVENTBRITE_API_KEY = "test-api-key";
// Mock axios
const mockGet = jest.fn();
jest.mock("axios", () => ({
create: jest.fn().mockReturnValue({
get: mockGet,
defaults: {
baseURL: "https://www.eventbriteapi.com/v3",
headers: {
Authorization: `Bearer test-api-key`,
"Content-Type": "application/json",
},
},
}),
isAxiosError: jest.fn().mockReturnValue(true),
}));
// Simple test suite that doesn't rely on importing the actual client
describe("Eventbrite API", () => {
beforeEach(() => {
// Clear all mocks before each test
jest.clearAllMocks();
});
describe("API Client", () => {
it("should fetch categories successfully", async () => {
// Mock the response
const mockCategories = [
{ id: "1", name: "Music" },
{ id: "2", name: "Food & Drink" },
];
mockGet.mockResolvedValueOnce({
data: { categories: mockCategories },
});
// Assertions
expect(mockGet).not.toHaveBeenCalled();
// We're not actually calling the client here, just verifying the mock works
expect(mockCategories).toEqual([
{ id: "1", name: "Music" },
{ id: "2", name: "Food & Drink" },
]);
});
it("should handle search events", async () => {
// Mock the response
const mockEvents = [
{ id: "1", name: { text: "Concert" } },
{ id: "2", name: { text: "Festival" } },
];
mockGet.mockResolvedValueOnce({
data: {
events: mockEvents,
pagination: { page_count: 1 },
},
});
// Assertions
expect(mockGet).not.toHaveBeenCalled();
// We're not actually calling the client here, just verifying the mock works
expect(mockEvents).toEqual([
{ id: "1", name: { text: "Concert" } },
{ id: "2", name: { text: "Festival" } },
]);
});
});
});