Skip to content

Commit 355d698

Browse files
feat(tabs): Add support for custom tabs (#163)
* feat(tabs): Add support for custom tabs * fix(cli): stop deleting md files after conversion It's no longer needed, causes issues at times, and isn't ideal anyways * chore(tests): update tests to reflect removal of file deletion * chore(lint): fix lint errors * chore(cleanup): rename componentTabs to tabsDictionary * fix(tabs): properly format tab names
1 parent 4056530 commit 355d698

File tree

13 files changed

+458
-90
lines changed

13 files changed

+458
-90
lines changed

cli/__tests__/convertToMDX.test.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import { readFile, writeFile, unlink } from 'fs/promises'
1+
import { readFile, writeFile } from 'fs/promises'
22
import { glob } from 'glob'
33
import { convertToMDX } from '../convertToMDX.ts'
44

55
jest.mock('fs/promises', () => ({
66
readFile: jest.fn(),
77
writeFile: jest.fn(),
8-
unlink: jest.fn(),
98
access: jest.fn().mockResolvedValue(undefined), // Mock access to always resolve (file exists)
109
}))
1110

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

135-
it('should delete the original file after conversion', async () => {
136-
const mockContent = '# Test Content\nSome text here'
137-
;(glob as unknown as jest.Mock).mockResolvedValue(['test.md'])
138-
;(readFile as jest.Mock).mockResolvedValue(mockContent)
139-
140-
await convertToMDX('test.md')
141-
142-
expect(writeFile).toHaveBeenCalledWith('test.mdx', mockContent)
143-
expect(unlink).toHaveBeenCalledWith('test.md')
144-
})
145-
146134
it('should convert HTML comments in MD content to MDX format', async () => {
147135
const mockContent = '# Test Content\n<!-- This is a comment in the MD content -->\nSome text here\n<!-- Another comment\nspanning multiple lines -->'
148136
const expectedContent = '# Test Content\n{/* This is a comment in the MD content */}\nSome text here\n{/* Another comment\nspanning multiple lines */}'

cli/convertToMDX.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { readFile, writeFile, unlink, access } from 'fs/promises'
1+
import { readFile, writeFile, access } from 'fs/promises'
22
import { glob } from 'glob'
33
import path from 'path'
44

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

9191
await writeFile(file + 'x', processedContent)
92-
await unlink(file)
9392
}
9493

9594
export async function convertToMDX(globPath: string): Promise<void> {

0 commit comments

Comments
 (0)