Skip to main content
Glama
mocks.js2.38 kB
/** * Mock helpers for apple-tools-mcp tests */ import { vi } from 'vitest' /** * Creates a mock for fs module */ export function createFsMock() { return { readFileSync: vi.fn(), writeFileSync: vi.fn(), existsSync: vi.fn().mockReturnValue(true), statSync: vi.fn().mockReturnValue({ isFile: () => true, isDirectory: () => true, mtime: new Date() }), readdirSync: vi.fn().mockReturnValue([]), unlinkSync: vi.fn(), mkdirSync: vi.fn() } } /** * Creates a mock for child_process spawnSync */ export function createSpawnSyncMock(output = '', error = null) { return vi.fn().mockReturnValue({ stdout: Buffer.from(output), stderr: Buffer.from(error || ''), status: error ? 1 : 0, error: error ? new Error(error) : null }) } /** * Sample EMLX file content for testing */ export const sampleEmlx = `From: John Doe <john@example.com> To: Jane Smith <jane@example.com> Subject: Test Email Subject Date: Mon, 1 Jan 2024 12:00:00 -0800 Message-ID: <test123@example.com> Content-Type: text/plain; charset="utf-8" This is the body of the test email. It has multiple lines. ` /** * Sample email with HTML body */ export const sampleHtmlEmail = `From: sender@example.com To: recipient@example.com Subject: HTML Email Date: Tue, 2 Jan 2024 10:00:00 -0800 Content-Type: text/html; charset="utf-8" <html><body><p>This is <b>bold</b> text.</p></body></html> ` /** * Sample email with attachment */ export const sampleEmailWithAttachment = `From: sender@example.com To: recipient@example.com Subject: Email with Attachment Date: Wed, 3 Jan 2024 14:00:00 -0800 Content-Type: multipart/mixed; boundary="boundary123" Content-Disposition: attachment; filename="document.pdf" --boundary123 Content-Type: text/plain Body text here. --boundary123-- ` /** * Sample SQLite query result for messages */ export const sampleMessagesResult = [ { ROWID: 1, date: 700000000000000000, // Mac Absolute Time text: 'Hello, how are you?', handle_id: 'john@example.com', chat_id: 1, display_name: 'John', participant_count: 2 } ] /** * Sample calendar event result */ export const sampleCalendarEvent = { ROWID: 1, summary: 'Team Meeting', start_date: 757382400, // Mac Absolute Time end_date: 757386000, calendar_title: 'Work', location_title: 'Conference Room A', all_day: 0 }

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/sfls1397/Apple-Tools-MCP'

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