Skip to content

Commit

Permalink
feat: Add parser definition tests
Browse files Browse the repository at this point in the history
  • Loading branch information
spring-raining committed Jul 20, 2020
1 parent f1afb20 commit a27d0ab
Showing 1 changed file with 118 additions and 0 deletions.
118 changes: 118 additions & 0 deletions tests/defs.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import { VFM } from '../src';

it('has valid inlineMethods', () => {
const vfm = VFM({ partial: true }).freeze();
expect(vfm.Parser.prototype.inlineMethods).toEqual([
'escape',
'autoLink',
'url',
'email',
'html',
'link',
'inlineNote',
'footnoteCall',
'reference',
'strong',
'emphasis',
'deletion',
'code',
'break',
'ruby',
'math',
'text',
]);
});

it('has valid blockMethods', () => {
const vfm = VFM({ partial: true }).freeze();
expect(vfm.Parser.prototype.blockMethods).toEqual([
'yamlFrontMatter',
'blankLine',
'indentedCode',
'fencedCode',
'math',
'blockquote',
'atxHeading',
'thematicBreak',
'list',
'setextHeading',
'shortcode',
'html',
'footnoteDefinition',
'definition',
'table',
'fencedBlock',
'paragraph',
]);
});

it('has valid interruptParagraph', () => {
const vfm = VFM({ partial: true }).freeze();
const interrupters = vfm.Parser.prototype.interruptParagraph.map(
([name]: string[]) => name,
);
expect(interrupters).toEqual([
'math',
'thematicBreak',
'list',
'atxHeading',
'fencedCode',
'blockquote',
'html',
'setextHeading',
'definition',
]);
});

it('has valid interruptList', () => {
const vfm = VFM({ partial: true }).freeze();
const interrupters = vfm.Parser.prototype.interruptList.map(
([name]: string[]) => name,
);
expect(interrupters).toEqual([
'math',
'atxHeading',
'fencedCode',
'thematicBreak',
'definition',
]);
});

it('has valid interruptBlockquote', () => {
const vfm = VFM({ partial: true }).freeze();
const interrupters = vfm.Parser.prototype.interruptBlockquote.map(
([name]: string[]) => name,
);
expect(interrupters).toEqual([
'math',
'indentedCode',
'fencedCode',
'atxHeading',
'setextHeading',
'thematicBreak',
'html',
'list',
'definition',
]);
});

it('has valid interruptFootnoteDefinition', () => {
const vfm = VFM({ partial: true }).freeze();
const interrupters = vfm.Parser.prototype.interruptFootnoteDefinition.map(
([name]: string[]) => name,
);
expect(interrupters).toEqual([
'blankLine',
'fencedCode',
'blockquote',
'atxHeading',
'thematicBreak',
'list',
'setextHeading',
'html',
'definition',
'table',
'fencedBlock',
'footnoteDefinition',
]);
});

0 comments on commit a27d0ab

Please sign in to comment.