Skip to content

Commit c8cc3eb

Browse files
committed
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 562525d commit c8cc3eb

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
@@ -203,8 +203,16 @@ Pops up this menu.
203203
it('should handle module with exported class in multi-package mode', async () => {
204204
const moduleContent = `# BrowserWindow
205205
206+
_Main process_
207+
206208
Create and control browser windows.
207209
210+
## Methods
211+
212+
### \`BrowserWindow.getAllWindows()\`
213+
214+
Returns \`BrowserWindow[]\` - An array of all opened browser windows.
215+
208216
## Class: BrowserWindow
209217
210218
### Instance Methods
@@ -285,12 +293,27 @@ Fired when the navigation is done.
285293
_Main process_
286294
287295
Main process module.
296+
297+
## Methods
298+
299+
### \`app.quit()\`
300+
301+
Quit the application.
288302
`;
289303
const rendererProcessContent = `# contextBridge
290304
291305
_Renderer process_
292306
293307
Renderer process module.
308+
309+
## Methods
310+
311+
### \`contextBridge.exposeInMainWorld(apiKey, api)\`
312+
313+
* \`apiKey\` string
314+
* \`api\` any
315+
316+
Expose API to renderer.
294317
`;
295318

296319
const mainPath = path.join(tempDir, 'docs', 'api', 'app.md');
@@ -449,7 +472,15 @@ This has no proper structure for parsing.
449472
it('should generate correct website and repo URLs', async () => {
450473
const moduleContent = `# testModule
451474
475+
_Main process_
476+
452477
Test module.
478+
479+
## Methods
480+
481+
### \`testModule.test()\`
482+
483+
Test method.
453484
`;
454485

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

492+
expect(result.length).toBeGreaterThan(0);
461493
const testModule = result[0];
494+
expect(testModule).toBeDefined();
462495
expect(testModule.websiteUrl).toContain('/docs/api/test-module');
463496
expect(testModule.repoUrl).toContain('v2.0.0/docs/api/test-module.md');
464497
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)