forked from umijs/dumi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(preset): add header case for remark
- Loading branch information
1 parent
b44f0b0
commit 2b5bc7c
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
packages/preset-dumi/src/transformer/fixtures/raw/remark-header.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# H1 | ||
|
||
## H2 | ||
|
||
### H3 with <Badge>I will be ignored</Badge> |
25 changes: 25 additions & 0 deletions
25
packages/preset-dumi/src/transformer/test/remark-header.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import remark from '../remark'; | ||
|
||
describe('basic example', () => { | ||
const FILE_PATH = path.join(__dirname, '../fixtures/raw/remark-header.md'); | ||
|
||
it('transform md to jsx', () => { | ||
const result = remark(fs.readFileSync(FILE_PATH).toString(), { | ||
fileAbsPath: FILE_PATH, | ||
strategy: 'default', | ||
previewLangs: [], | ||
}); | ||
|
||
expect(result.data.slugs).toEqual([ | ||
{ depth: 1, value: 'H1', heading: 'h1' }, | ||
{ depth: 2, value: 'H2', heading: 'h2' }, | ||
{ | ||
depth: 3, | ||
value: 'H3 with ', | ||
heading: 'h3-with-i-will-be-ignored', | ||
}, | ||
]); | ||
}); | ||
}); |