Skip to content

Commit d7687f1

Browse files
authored
Merge pull request #1570 from IgniteUI/ipetrov/igniteui-mcp-tests
test(igniteui-mcp): add vitest unit test suite for MCP server
2 parents 8c81f9d + dc77fc2 commit d7687f1

14 files changed

Lines changed: 4441 additions & 3289 deletions

File tree

packages/igniteui-mcp/docs-backend/tests-docs-backend/UnitTest1.cs renamed to packages/igniteui-mcp/docs-backend/tests-docs-backend/DocsControllerTests.cs

File renamed without changes.

packages/igniteui-mcp/igniteui-doc-mcp/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ Add to `.vscode/mcp.json`:
5454
"igniteui": {
5555
"command": "npx",
5656
"args": ["-y", "igniteui-cli@next", "mcp"]
57-
},
57+
}
5858
}
5959
}
6060
```
6161

6262
### Claude Desktop
63-
If IgniteUi ClI is globbaly installed you can configure the MCP like this:
63+
If Ignite UI CLI is globally installed you can configure the MCP like this:
6464

6565
Add to `claude_desktop_config.json`:
6666

@@ -70,12 +70,12 @@ Add to `claude_desktop_config.json`:
7070
"igniteui": {
7171
"command": "npx",
7272
"args": ["-y", "igniteui-cli@next", "mcp"]
73-
},
73+
}
7474
}
7575
}
7676
```
7777
### Cursor
78-
If IgniteUi ClI is globbaly installed you can configure the MCP like this:
78+
If Ignite UI CLI is globally installed you can configure the MCP like this:
7979

8080
Add to Cursor MCP settings:
8181

@@ -85,7 +85,7 @@ Add to Cursor MCP settings:
8585
"igniteui": {
8686
"command": "npx",
8787
"args": ["-y", "igniteui-cli@next", "mcp"]
88-
},
88+
}
8989
}
9090
}
9191
```

packages/igniteui-mcp/igniteui-doc-mcp/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
"scripts": {
3232
"build": "tsc && npx tsx scripts/build.ts",
3333
"start": "node dist/index.js",
34+
"test": "vitest run",
35+
"test:watch": "vitest",
36+
"coverage": "vitest run --coverage",
3437
"build:db": "npx tsx scripts/build-db.ts",
3538
"inspector": "npx @modelcontextprotocol/inspector dist/index.js",
3639
"clear": "npx tsx -e \"import{rmSync}from'fs';rmSync('dist',{recursive:true,force:true})\"",
@@ -104,6 +107,7 @@
104107
"openai": "^6.22.0",
105108
"tsx": "^4.21.0",
106109
"typedoc": "^0.28.6",
110+
"vitest": "^3.0.0",
107111
"typedoc-plugin-markdown": "^4.4.1",
108112
"typescript": "^5.8.3"
109113
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import { describe, expect, it } from 'vitest';
2+
import { PLATFORMS, PLATFORM_CONFIGS, getPlatforms, getPlatformConfig } from '../../config/platforms.js';
3+
import type { Platform, PlatformConfig } from '../../config/platforms.js';
4+
5+
describe('PLATFORMS', () => {
6+
it('includes angular, react, and webcomponents', () => {
7+
expect(PLATFORMS).toContain('angular');
8+
expect(PLATFORMS).toContain('react');
9+
expect(PLATFORMS).toContain('webcomponents');
10+
});
11+
12+
it('has exactly 3 entries', () => {
13+
expect(PLATFORMS).toHaveLength(3);
14+
});
15+
});
16+
17+
describe('PLATFORM_CONFIGS', () => {
18+
it('has a config for every platform', () => {
19+
for (const platform of PLATFORMS) {
20+
expect(PLATFORM_CONFIGS[platform]).toBeDefined();
21+
expect(PLATFORM_CONFIGS[platform].key).toBe(platform);
22+
}
23+
});
24+
25+
it('angular uses markdown-index api source', () => {
26+
expect(PLATFORM_CONFIGS.angular.apiSource.kind).toBe('markdown-index');
27+
});
28+
29+
it('react uses typedoc-json api source with a jsonPath', () => {
30+
const source = PLATFORM_CONFIGS.react.apiSource;
31+
expect(source.kind).toBe('typedoc-json');
32+
if (source.kind === 'typedoc-json') {
33+
expect(source.jsonPath).toBeDefined();
34+
expect(source.jsonPath).toContain('.json');
35+
}
36+
});
37+
38+
it('webcomponents uses markdown-index api source', () => {
39+
expect(PLATFORM_CONFIGS.webcomponents.apiSource.kind).toBe('markdown-index');
40+
});
41+
42+
it('each config has required fields', () => {
43+
for (const platform of PLATFORMS) {
44+
const config = PLATFORM_CONFIGS[platform];
45+
expect(config.displayName).toBeTruthy();
46+
expect(config.submodulePath).toBeTruthy();
47+
expect(config.docsPath).toBeTruthy();
48+
}
49+
});
50+
});
51+
52+
describe('getPlatforms()', () => {
53+
it('returns an array of PlatformConfig objects', () => {
54+
const platforms = getPlatforms();
55+
expect(platforms).toBeInstanceOf(Array);
56+
expect(platforms.length).toBeGreaterThan(0);
57+
});
58+
59+
it('returns one config per platform', () => {
60+
const platforms = getPlatforms();
61+
expect(platforms).toHaveLength(PLATFORMS.length);
62+
});
63+
64+
it('each returned config has a key matching a PLATFORMS entry', () => {
65+
const keys = getPlatforms().map(p => p.key);
66+
for (const platform of PLATFORMS) {
67+
expect(keys).toContain(platform);
68+
}
69+
});
70+
});
71+
72+
describe('getPlatformConfig()', () => {
73+
it('returns the correct config for angular', () => {
74+
const config = getPlatformConfig('angular');
75+
expect(config.key).toBe('angular');
76+
expect(config.displayName).toBe('Angular');
77+
});
78+
79+
it('returns the correct config for react', () => {
80+
const config = getPlatformConfig('react');
81+
expect(config.key).toBe('react');
82+
expect(config.displayName).toBe('React');
83+
});
84+
85+
it('returns the correct config for webcomponents', () => {
86+
const config = getPlatformConfig('webcomponents');
87+
expect(config.key).toBe('webcomponents');
88+
expect(config.displayName).toBe('Web Components');
89+
});
90+
});

0 commit comments

Comments
 (0)