mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-04-18 00:03:23 +02:00
Removed ~29 tests that were adding noise rather than coverage: - Registration boilerplate tests (16): redundant with registrations.test.ts - Redundant role/type checks (3): consolidated into behavioral tests - "Should not throw" tests (6): consolidated into single lifecycle test - Constant identity tests (2): provided no safety net - expect(true).toBe(true) test (1): replaced with actual assertion - Weak capability test (1): removed, handler check already exists Strengthened remaining tests: - Resource templates test now verifies specific resource names - File resources test now asserts registerResource was called Test count: 124 → 95 (29 removed) Coverage unchanged at ~71% Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import { describe, it, expect, vi } from 'vitest';
|
|
import { createServer } from '../server/index.js';
|
|
|
|
describe('Server Factory', () => {
|
|
describe('createServer', () => {
|
|
it('should return a ServerFactoryResponse object', () => {
|
|
const result = createServer();
|
|
|
|
expect(result).toHaveProperty('server');
|
|
expect(result).toHaveProperty('cleanup');
|
|
});
|
|
|
|
it('should return a cleanup function', () => {
|
|
const { cleanup } = createServer();
|
|
|
|
expect(typeof cleanup).toBe('function');
|
|
});
|
|
|
|
it('should create an McpServer instance', () => {
|
|
const { server } = createServer();
|
|
|
|
expect(server).toBeDefined();
|
|
expect(server.server).toBeDefined();
|
|
});
|
|
|
|
it('should have an oninitialized handler set', () => {
|
|
const { server } = createServer();
|
|
|
|
expect(server.server.oninitialized).toBeDefined();
|
|
});
|
|
|
|
it('should allow multiple servers to be created', () => {
|
|
const result1 = createServer();
|
|
const result2 = createServer();
|
|
|
|
expect(result1.server).toBeDefined();
|
|
expect(result2.server).toBeDefined();
|
|
expect(result1.server).not.toBe(result2.server);
|
|
});
|
|
});
|
|
});
|