Skip to main content
Glama

Timezone MCP Server

by sam-artuso
timezone.e2e.spec.tsβ€’4 kB
import { describe, it, expect, beforeAll, afterAll } from 'vitest' import { Test, TestingModule } from '@nestjs/testing' import { INestApplication } from '@nestjs/common' import { TimezoneModule } from '../src/timezone/timezone.module' import { TimezoneController } from '../src/timezone/timezone.controller' import { TimezoneService } from '../src/timezone/timezone.service' describe('Timezone API (e2e)', () => { let app: INestApplication let service: TimezoneService beforeAll(async () => { // Set NODE_ENV to development so controller gets registered process.env.NODE_ENV = 'development' const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [TimezoneModule.forRoot()], }).compile() app = moduleFixture.createNestApplication() await app.init() // Get service directly for testing service = app.get(TimezoneService) }) afterAll(async () => { await app.close() }) describe('Service Integration', () => { it('should return list of timezones', () => { const result = service.getAvailableTimezones() expect(result).toBeDefined() expect(Array.isArray(result)).toBe(true) expect(result.length).toBeGreaterThan(0) }) it('should include common timezones', () => { const timezones = service.getAvailableTimezones() expect(timezones).toContain('America/New_York') expect(timezones).toContain('Europe/London') expect(timezones).toContain('Asia/Tokyo') }) it('should return time for America/New_York', () => { const result = service.getTimeInTimezone('America/New_York') expect(result).toBeDefined() expect(result.timezone).toBe('America/New_York') expect(result).toHaveProperty('datetime_local') expect(result).toHaveProperty('datetime_utc') expect(result).toHaveProperty('timezone_offset') expect(result).toHaveProperty('timestamp') expect(typeof result.datetime_local).toBe('string') expect(typeof result.datetime_utc).toBe('string') expect(typeof result.timezone_offset).toBe('string') expect(typeof result.timestamp).toBe('number') }) it('should return time for Europe/London', () => { const result = service.getTimeInTimezone('Europe/London') expect(result).toBeDefined() expect(result.timezone).toBe('Europe/London') expect(result).toHaveProperty('datetime_local') expect(result).toHaveProperty('datetime_utc') expect(result).toHaveProperty('timezone_offset') expect(result).toHaveProperty('timestamp') }) it('should return time for Asia/Tokyo', () => { const result = service.getTimeInTimezone('Asia/Tokyo') expect(result).toBeDefined() expect(result.timezone).toBe('Asia/Tokyo') expect(result).toHaveProperty('datetime_local') expect(result).toHaveProperty('datetime_utc') expect(result).toHaveProperty('timezone_offset') expect(result).toHaveProperty('timestamp') }) it('should throw error for invalid timezone', () => { expect(() => { service.getTimeInTimezone('Invalid/Timezone') }).toThrow('Invalid timezone') }) it('should have consistent timestamp across different timezones', () => { const nyTime = service.getTimeInTimezone('America/New_York') const londonTime = service.getTimeInTimezone('Europe/London') // Timestamps should be within 100ms of each other (same moment in time) expect(Math.abs(nyTime.timestamp - londonTime.timestamp)).toBeLessThan(100) }) }) describe('Module Integration', () => { it('should have TimezoneController in development mode', () => { // Controller is only registered when NODE_ENV=development const controller = app.get(TimezoneController) expect(controller).toBeDefined() }) it('should have TimezoneService', () => { // Service is always available (needed by MCP tools) expect(service).toBeDefined() }) }) })

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/sam-artuso/demo-mcp'

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