Skip to main content
Glama

Unleash MCP (Feature Toggle)

mark-features-stale.test.ts2.64 kB
import { markFeaturesStale } from '../../src/unleash/mark-features-stale.js'; import { client } from '../../src/unleash/unleash-client.js'; import { logger } from '../../src/logger.js'; // Mock dependencies jest.mock('../../src/unleash/unleash-client.js', () => ({ client: { post: jest.fn() } })); jest.mock('../../src/logger.js', () => ({ logger: { info: jest.fn(), error: jest.fn() } })); describe('Mark Features Stale API', () => { const mockProjectId = 'test-project'; const mockFeatures = ['feature-1', 'feature-2', 'feature-3']; beforeEach(() => { jest.clearAllMocks(); }); test('markFeaturesStale should mark features as stale correctly', async () => { // Mock successful response const mockResponse = { data: { success: true } }; (client.post as jest.Mock).mockResolvedValue(mockResponse); // Call the function to mark as stale await markFeaturesStale(mockProjectId, mockFeatures, true); // Verify API call expect(client.post).toHaveBeenCalledWith( `/api/admin/projects/${mockProjectId}/stale`, { features: mockFeatures, stale: true } ); // Verify logging expect(logger.info).toHaveBeenCalledWith( expect.stringContaining(`Successfully marked ${mockFeatures.length} features as stale`) ); }); test('markFeaturesStale should mark features as not stale correctly', async () => { // Mock successful response const mockResponse = { data: { success: true } }; (client.post as jest.Mock).mockResolvedValue(mockResponse); // Call the function to mark as not stale await markFeaturesStale(mockProjectId, mockFeatures, false); // Verify API call expect(client.post).toHaveBeenCalledWith( `/api/admin/projects/${mockProjectId}/stale`, { features: mockFeatures, stale: false } ); // Verify logging expect(logger.info).toHaveBeenCalledWith( expect.stringContaining(`Successfully marked ${mockFeatures.length} features as not stale`) ); }); test('markFeaturesStale should handle errors correctly', async () => { // Mock error response const mockError = new Error('API error'); (client.post as jest.Mock).mockRejectedValue(mockError); // Call the function and expect it to throw await expect( markFeaturesStale(mockProjectId, mockFeatures, true) ).rejects.toThrow(); // Verify error logging expect(logger.error).toHaveBeenCalledWith( expect.stringContaining(`Error marking features as stale`), expect.any(Error) ); }); });

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/cuongtl1992/unleash-mcp'

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