Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions cli/__tests__/convertToMDX.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { readFile, writeFile, unlink } from 'fs/promises'
import { readFile, writeFile } from 'fs/promises'
import { glob } from 'glob'
import { convertToMDX } from '../convertToMDX.ts'

jest.mock('fs/promises', () => ({
readFile: jest.fn(),
writeFile: jest.fn(),
unlink: jest.fn(),
access: jest.fn().mockResolvedValue(undefined), // Mock access to always resolve (file exists)
}))

Expand Down Expand Up @@ -132,17 +131,6 @@ import Example1 from './Example1.html?raw'
expect(writeFile).toHaveBeenCalledWith('test.mdx', expectedContent)
})

it('should delete the original file after conversion', async () => {
const mockContent = '# Test Content\nSome text here'
;(glob as unknown as jest.Mock).mockResolvedValue(['test.md'])
;(readFile as jest.Mock).mockResolvedValue(mockContent)

await convertToMDX('test.md')

expect(writeFile).toHaveBeenCalledWith('test.mdx', mockContent)
expect(unlink).toHaveBeenCalledWith('test.md')
})

it('should convert HTML comments in MD content to MDX format', async () => {
const mockContent = '# Test Content\n<!-- This is a comment in the MD content -->\nSome text here\n<!-- Another comment\nspanning multiple lines -->'
const expectedContent = '# Test Content\n{/* This is a comment in the MD content */}\nSome text here\n{/* Another comment\nspanning multiple lines */}'
Expand Down
3 changes: 1 addition & 2 deletions cli/convertToMDX.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { readFile, writeFile, unlink, access } from 'fs/promises'
import { readFile, writeFile, access } from 'fs/promises'
import { glob } from 'glob'
import path from 'path'

Expand Down Expand Up @@ -89,7 +89,6 @@ async function processFile(file: string): Promise<void> {
)

await writeFile(file + 'x', processedContent)
await unlink(file)
}

export async function convertToMDX(globPath: string): Promise<void> {
Expand Down
Loading