Skip to main content
Glama
addWatching.test.ts1.89 kB
import { addWatchingTool } from './addWatching.js'; import { jest, describe, it, expect } from '@jest/globals'; import type { Backlog } from 'backlog-js'; import { createTranslationHelper } from '../createTranslationHelper.js'; describe('addWatchingTool', () => { const mockBacklog: Partial<Backlog> = { postWatchingListItem: jest.fn<() => Promise<any>>().mockResolvedValue({ id: 1, resourceAlreadyRead: false, note: 'Watching this issue', type: 'issue', issue: { id: 1000, projectId: 100, issueKey: 'TEST-1', summary: 'Test issue', }, created: '2023-01-01T00:00:00Z', updated: '2023-01-01T00:00:00Z', }), }; const mockTranslationHelper = createTranslationHelper(); const tool = addWatchingTool(mockBacklog as Backlog, mockTranslationHelper); it('returns created watching item as formatted JSON text', async () => { const result = await tool.handler({ issueIdOrKey: 'TEST-1', note: 'Watching this issue', }); if (Array.isArray(result)) { throw new Error('Unexpected array result'); } expect(result).toHaveProperty('id'); expect(result.note).toBe('Watching this issue'); }); it('calls backlog.postWatchingListItem with correct params when using issue key', async () => { await tool.handler({ issueIdOrKey: 'TEST-1', note: 'Watching this issue', }); expect(mockBacklog.postWatchingListItem).toHaveBeenCalledWith({ issueIdOrKey: 'TEST-1', note: 'Watching this issue', }); }); it('calls backlog.postWatchingListItem with correct params when using issue ID', async () => { await tool.handler({ issueIdOrKey: 1, note: 'Important issue', }); expect(mockBacklog.postWatchingListItem).toHaveBeenCalledWith({ issueIdOrKey: 1, note: 'Important issue', }); }); });

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/nulab/backlog-mcp-server'

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