Skip to content

Commit

Permalink
added logs for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
vishvamsinh28 committed Oct 18, 2024
1 parent 0db7bc9 commit ecf927e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/build-post-list.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ describe('buildPostList', () => {

mkdirSync(join(tempDir, 'blog'), { recursive: true });
writeFileSync(join(tempDir, 'blog', 'release-notes-2.1.0.mdx'), '---\ntitle: Release Notes 2.1.0\n---\nThis is a release note.');
console.log('Written blog post file:', join(tempDir, 'blog', 'release-notes-2.1.0.mdx'));

mkdirSync(join(tempDir, 'docs'), { recursive: true });
writeFileSync(join(tempDir, 'docs', 'index.mdx'), '---\ntitle: Docs Home\n---\nThis is the documentation homepage.');
console.log('Written docs index file:', join(tempDir, 'docs', 'index.mdx'));

mkdirSync(join(tempDir, 'about'), { recursive: true });
writeFileSync(join(tempDir, 'about', 'index.mdx'), '---\ntitle: About Us\n---\nThis is the about page.');
console.log('Written about file:', join(tempDir, 'about', 'index.mdx'));

mkdirSync(join(tempDir, 'docs', 'reference', 'specification'), { recursive: true });
});
Expand All @@ -35,19 +38,26 @@ describe('buildPostList', () => {
});

it('builds a post list and writes the result to a file', async () => {
console.log('Post directories:', postDirectories);
console.log('Output file path:', writeFilePath);

await buildPostList(postDirectories, tempDir, writeFilePath);
console.log('Post list built and written to:', writeFilePath);

const outputExists = existsSync(writeFilePath);
console.log('Output file exists:', outputExists);
expect(outputExists).toBe(true);

const output = JSON.parse(readFileSync(writeFilePath, 'utf-8'));
console.log('Output file content:', output)

expect(output).toHaveProperty('docs');
expect(output).toHaveProperty('blog');
expect(output).toHaveProperty('about');
expect(output).toHaveProperty('docsTree');

const blogEntry = output.blog.find(item => item.slug === '/blog/release-notes-2.1.0');
console.log('Blog entry found:', blogEntry);
expect(blogEntry).toBeDefined();
expect(blogEntry.title).toBe('Release Notes 2.1.0');
});
Expand Down

0 comments on commit ecf927e

Please sign in to comment.