Skip to main content
Glama
pshempel

MCP Time Server Node

by pshempel
calculateDuration.integration.test.ts1.82 kB
import { createTestEnvironment } from '../helpers/setup'; import { callTool } from '../helpers/tools'; describe('calculate_duration integration', () => { it('should execute calculate_duration with basic parameters', async () => { const { client, cleanup } = await createTestEnvironment(); try { const result = await callTool(client, 'calculate_duration', { start_time: '2024-01-15T10:00:00.000Z', end_time: '2024-01-15T15:30:00.000Z', }); expect(result.hours).toBe(5.5); expect(result.minutes).toBe(330); expect(result.seconds).toBe(19800); expect(result.milliseconds).toBe(19800000); expect(result.days).toBeCloseTo(0.229167, 5); expect(result.formatted).toBe('5 hours 30 minutes'); expect(result.is_negative).toBe(false); } finally { await cleanup(); } }); it('should handle negative duration', async () => { const { client, cleanup } = await createTestEnvironment(); try { const result = await callTool(client, 'calculate_duration', { start_time: '2024-01-15T15:00:00.000Z', end_time: '2024-01-15T10:00:00.000Z', }); expect(result.hours).toBe(-5); expect(result.is_negative).toBe(true); expect(result.formatted).toMatch(/^-5 hours/); } finally { await cleanup(); } }); it('should handle calculate_duration with timezone', async () => { const { client, cleanup } = await createTestEnvironment(); try { const result = await callTool(client, 'calculate_duration', { start_time: '2024-01-15T10:00:00', end_time: '2024-01-15T15:00:00', timezone: 'America/New_York', }); expect(result.hours).toBe(5); expect(result.minutes).toBe(300); } finally { await cleanup(); } }); });

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/pshempel/mcp-time-server-node'

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