Skip to main content
Glama

Unleash MCP (Feature Toggle)

set-strategy-sort-order.test.ts1.7 kB
import { setStrategySortOrder } from '../src/unleash/set-strategy-sort-order.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('setStrategySortOrder', () => { beforeEach(() => { jest.clearAllMocks(); }); test('should set strategy sort order successfully', async () => { // Mock successful API response (client.post as jest.Mock).mockResolvedValue({}); // Call the function const strategyIds = ['strategy-3', 'strategy-1', 'strategy-2']; const result = await setStrategySortOrder('default', 'test-flag', 'development', strategyIds); // Verify API call expect(client.post).toHaveBeenCalledWith( '/api/admin/projects/default/features/test-flag/environments/development/strategies/set-sort-order', strategyIds ); // Verify result expect(result).toBe(true); expect(logger.info).toHaveBeenCalled(); }); test('should handle errors', async () => { // Mock API error const error = new Error('API Error'); (client.post as jest.Mock).mockRejectedValue(error); // Call the function const strategyIds = ['strategy-3', 'strategy-1', 'strategy-2']; const result = await setStrategySortOrder('default', 'test-flag', 'development', strategyIds); // Verify API call expect(client.post).toHaveBeenCalled(); // Verify error handling expect(result).toBe(false); expect(logger.error).toHaveBeenCalled(); }); });

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