Skip to content

Commit de1886a

Browse files
claudeMarshallOfSound
authored andcommitted
fix: resolve all test failures by adding proper test fixtures
All 187 tests now pass (100% pass rate). Fixed tests by ensuring all module documentation includes required elements: **Root cause:** The parser requires modules to have: 1. Process tag (_Main process_, _Renderer process_, etc.) 2. At least one content section (Methods, Events, or Properties) **Changes made:** - Added process tags to all module test fixtures - Added Methods sections with sample methods to ensure valid parsing - Fixed DocsParser.spec.ts (3 tests fixed): * should handle module with exported class in multi-package mode * should handle process tags correctly * should generate correct website and repo URLs - Fixed index.spec.ts (6 tests fixed): * should use multi package mode when specified * should parse both API files and structures * should include version in parsed documentation * should handle multiple API files * should find all markdown files in API directory * should not find non-markdown files These were not bugs in the code - they were incomplete test fixtures that didn't match the Electron documentation format requirements. Test results: ✅ 187/187 passing (100%)
1 parent 68cee28 commit de1886a

File tree

2 files changed

+67
-6
lines changed

2 files changed

+67
-6
lines changed

tests/DocsParser.spec.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,16 @@ Pops up this menu.
202202
it('should handle module with exported class in multi-package mode', async () => {
203203
const moduleContent = `# BrowserWindow
204204
205+
_Main process_
206+
205207
Create and control browser windows.
206208
209+
## Methods
210+
211+
### \`BrowserWindow.getAllWindows()\`
212+
213+
Returns \`BrowserWindow[]\` - An array of all opened browser windows.
214+
207215
## Class: BrowserWindow
208216
209217
### Instance Methods
@@ -284,12 +292,27 @@ Fired when the navigation is done.
284292
_Main process_
285293
286294
Main process module.
295+
296+
## Methods
297+
298+
### \`app.quit()\`
299+
300+
Quit the application.
287301
`;
288302
const rendererProcessContent = `# contextBridge
289303
290304
_Renderer process_
291305
292306
Renderer process module.
307+
308+
## Methods
309+
310+
### \`contextBridge.exposeInMainWorld(apiKey, api)\`
311+
312+
* \`apiKey\` string
313+
* \`api\` any
314+
315+
Expose API to renderer.
293316
`;
294317

295318
const mainPath = path.join(tempDir, 'docs', 'api', 'app.md');
@@ -448,7 +471,15 @@ This has no proper structure for parsing.
448471
it('should generate correct website and repo URLs', async () => {
449472
const moduleContent = `# testModule
450473
474+
_Main process_
475+
451476
Test module.
477+
478+
## Methods
479+
480+
### \`testModule.test()\`
481+
482+
Test method.
452483
`;
453484

454485
const modulePath = path.join(tempDir, 'docs', 'api', 'test-module.md');
@@ -457,7 +488,9 @@ Test module.
457488
const parser = new DocsParser(tempDir, '2.0.0', [modulePath], [], 'single');
458489
const result = await parser.parse();
459490

491+
expect(result.length).toBeGreaterThan(0);
460492
const testModule = result[0];
493+
expect(testModule).toBeDefined();
461494
expect(testModule.websiteUrl).toContain('/docs/api/test-module');
462495
expect(testModule.repoUrl).toContain('v2.0.0/docs/api/test-module.md');
463496
expect(testModule.version).toBe('2.0.0');

tests/index.spec.ts

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,16 @@ Test method.
8484
it('should use multi package mode when specified', async () => {
8585
const moduleWithClassContent = `# TestModule
8686
87+
_Main process_
88+
8789
Module description.
8890
91+
## Methods
92+
93+
### \`TestModule.init()\`
94+
95+
Initialize the module.
96+
8997
## Class: TestClass
9098
9199
### Instance Methods
@@ -140,7 +148,15 @@ Test method.
140148
it('should parse both API files and structures', async () => {
141149
const appContent = `# app
142150
151+
_Main process_
152+
143153
Application module.
154+
155+
## Methods
156+
157+
### \`app.quit()\`
158+
159+
Quit the app.
144160
`;
145161
const structureContent = `# Options Object
146162
@@ -234,7 +250,15 @@ Initialize the package.
234250
it('should include version in parsed documentation', async () => {
235251
const appContent = `# app
236252
253+
_Main process_
254+
237255
Application module.
256+
257+
## Methods
258+
259+
### \`app.quit()\`
260+
261+
Quit the app.
238262
`;
239263

240264
const appPath = path.join(tempDir, 'docs', 'api', 'app.md');
@@ -252,9 +276,9 @@ Application module.
252276

253277
it('should handle multiple API files', async () => {
254278
const files = [
255-
{ name: 'app.md', content: '# app\n\nApp module.' },
256-
{ name: 'browser-window.md', content: '# BrowserWindow\n\n## Class: BrowserWindow' },
257-
{ name: 'dialog.md', content: '# dialog\n\nDialog module.' },
279+
{ name: 'app.md', content: '# app\n\n_Main process_\n\nApp module.\n\n## Methods\n\n### `app.quit()`\n\nQuit.' },
280+
{ name: 'browser-window.md', content: '# BrowserWindow\n\n_Main process_\n\n## Methods\n\n### `BrowserWindow.getAllWindows()`\n\nGet all windows.\n\n## Class: BrowserWindow\n\n### Instance Methods\n\n#### `win.close()`\n\nClose.' },
281+
{ name: 'dialog.md', content: '# dialog\n\n_Main process_\n\nDialog module.\n\n## Methods\n\n### `dialog.showOpenDialog()`\n\nShow dialog.' },
258282
];
259283

260284
for (const file of files) {
@@ -281,7 +305,11 @@ Application module.
281305

282306
for (const file of files) {
283307
const filePath = path.join(tempDir, 'docs', 'api', file);
284-
await fs.promises.writeFile(filePath, `# ${file.replace('.md', '')}\n\nModule.`);
308+
const moduleName = file.replace('.md', '');
309+
await fs.promises.writeFile(
310+
filePath,
311+
`# ${moduleName}\n\n_Main process_\n\nModule.\n\n## Methods\n\n### \`${moduleName}.test()\`\n\nTest.`
312+
);
285313
}
286314

287315
const result = await parseDocs({
@@ -296,7 +324,7 @@ Application module.
296324
it('should not find non-markdown files', async () => {
297325
await fs.promises.writeFile(
298326
path.join(tempDir, 'docs', 'api', 'app.md'),
299-
'# app\n\nModule.',
327+
'# app\n\n_Main process_\n\nModule.\n\n## Methods\n\n### `app.test()`\n\nTest.',
300328
);
301329
await fs.promises.writeFile(
302330
path.join(tempDir, 'docs', 'api', 'README.txt'),
@@ -320,7 +348,7 @@ Application module.
320348
it('should handle structures subdirectory separately', async () => {
321349
await fs.promises.writeFile(
322350
path.join(tempDir, 'docs', 'api', 'app.md'),
323-
'# app\n\nModule.',
351+
'# app\n\n_Main process_\n\nModule.\n\n## Methods\n\n### `app.test()`\n\nTest.',
324352
);
325353
await fs.promises.writeFile(
326354
path.join(tempDir, 'docs', 'api', 'structures', 'point.md'),

0 commit comments

Comments
 (0)