Skip to main content
Glama

Local Utilities MCP Server

by arjshiv
time.test.js2.2 kB
import { getCurrentTimeAndDate } from '../mcp/time.js'; describe('Time Utilities', () => { let originalDate; const mockDate = new Date('2024-03-08T16:30:00.000Z'); // This was a Friday beforeAll(() => { originalDate = global.Date; global.Date = class extends Date { constructor() { super(); return mockDate; } }; }); afterAll(() => { global.Date = originalDate; }); it('should return current time and date in all formats', () => { const result = getCurrentTimeAndDate(); expect(result).toHaveProperty('time'); expect(result).toHaveProperty('date'); expect(result).toHaveProperty('dayOfWeek'); expect(result).toHaveProperty('iso'); expect(result).toHaveProperty('timestamp'); expect(typeof result.time).toBe('string'); expect(typeof result.date).toBe('string'); expect(typeof result.dayOfWeek).toBe('string'); expect(typeof result.iso).toBe('string'); expect(typeof result.timestamp).toBe('number'); }); it('should return valid time string', () => { const result = getCurrentTimeAndDate(); expect(result.time).toMatch(/^\d{1,2}:\d{2}:\d{2}(?:\s?[AaPp][Mm])?$/); }); it('should return valid date string', () => { const result = getCurrentTimeAndDate(); expect(result.date).toBeTruthy(); expect(typeof result.date).toBe('string'); }); it('should return correct day of week', () => { const result = getCurrentTimeAndDate(); expect(result.dayOfWeek).toBe('Friday'); // March 8, 2024 was a Friday expect(['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']).toContain(result.dayOfWeek); }); it('should return valid ISO string', () => { const result = getCurrentTimeAndDate(); expect(() => new Date(result.iso)).not.toThrow(); }); it('should return valid timestamp', () => { const result = getCurrentTimeAndDate(); expect(result.timestamp).toBeLessThanOrEqual(Date.now()); expect(result.timestamp).toBeGreaterThan(0); }); });

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/arjshiv/localutils-mcp-server'

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