Skip to main content
Glama
handlers.test.js1.76 kB
const axios = require('axios'); const MockAdapter = require('axios-mock-adapter'); // Import the PlexMCPServer class const PlexMCPServer = require('../../index.js'); describe('Handler Functions Tests', () => { let server; let mock; let mockAxios; beforeEach(() => { mockAxios = axios.create(); mock = new MockAdapter(mockAxios); server = new PlexMCPServer({ axios: mockAxios }); process.env.PLEX_TOKEN = 'test-token'; process.env.PLEX_URL = 'http://localhost:32400'; }); afterEach(() => { mock.restore(); delete process.env.PLEX_TOKEN; delete process.env.PLEX_URL; }); describe('handleGetCollections', () => { it('should handle API errors', async() => { mock.onGet().reply(500, 'Server Error'); const result = await server.handleGetCollections({}); expect(result.isError).toBe(true); expect(result.content[0].text).toContain('Error getting collections'); }); }); describe('Smart Playlist Creation', () => { it.skip('should handle smart playlist creation (disabled feature)', async() => { const mockResponse = { MediaContainer: { Metadata: [{ ratingKey: '456', title: 'Smart Test Playlist', smart: '1', playlistType: 'audio' }] } }; mock.onGet().reply(200, { MediaContainer: { machineIdentifier: 'test' } }); mock.onPost().reply(200, mockResponse); const result = await server.handleCreatePlaylist({ title: 'Smart Test Playlist', type: 'audio', smart: true }); expect(result.content[0].text).toContain('smart playlist'); expect(result.content[0].text).toContain('Smart Test Playlist'); }); }); });

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/vyb1ng/plex-mcp'

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