-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bcc5d9a
commit 51f691e
Showing
3 changed files
with
7 additions
and
21 deletions.
There are no files selected for viewing
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
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
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 |
---|---|---|
@@ -1,35 +1,21 @@ | ||
import { usePandocAnchoring } from './pandoc.js' | ||
|
||
describe('slugify', () => { | ||
test('should match pandoc anchoring', () => { | ||
// echo '# Coucou, comment ça va ?' | pandoc -f markdown -t html | ||
expect(slugify('Coucou, comment ça va ?')).toEqual('coucou-comment-ça-va') | ||
// echo '# [SHARED] How To Stylo?' | pandoc -f markdown -t html | ||
expect(slugify('[SHARED] How To Stylo?')).toEqual('shared-how-to-stylo') | ||
}) | ||
|
||
test('should match legacy export expectations', () => { | ||
// echo '# Coucou, comment ça va ?' | pandoc -f markdown -t html | ||
expect(slugify('Coucou, comment ça va ?', { diacritics: false })).toEqual('coucou-comment-ca-va') | ||
}) | ||
}) | ||
|
||
describe('usePandocAnchoring()', () => { | ||
test('generate expected anchors', () => { | ||
const getAnchor = usePandocAnchoring() | ||
|
||
expect(getAnchor('# Test')).toEqual('test') | ||
expect(getAnchor('## Section Title')).toEqual('section-title') | ||
expect(getAnchor('## Héo')).toEqual('héo') | ||
expect(getAnchor('## Héo')).toEqual('heo') | ||
}) | ||
|
||
test('handle duplicate headings', () => { | ||
const getAnchor = usePandocAnchoring() | ||
|
||
expect(getAnchor('## Héo')).toEqual('héo') | ||
expect(getAnchor('## Héo')).toEqual('héo-1') | ||
expect(getAnchor('## Héo')).toEqual('heo') | ||
expect(getAnchor('## Héo')).toEqual('heo-1') | ||
|
||
expect(getAnchor('## Héo 1')).toEqual('héo-1-1') | ||
expect(getAnchor('## Héo 1')).toEqual('héo-1-2') | ||
expect(getAnchor('## Héo 1')).toEqual('heo-1-1') | ||
expect(getAnchor('## Héo 1')).toEqual('heo-1-2') | ||
}) | ||
}) |