Skip to content

Commit

Permalink
test(gfm/table): add some test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
emmetzhang committed Nov 22, 2021
1 parent 611ad1a commit 7841ae6
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/specs/gfm/gfm.0.29.json
Expand Up @@ -47,6 +47,18 @@
"markdown": "| abc | def |\n| --- | --- |",
"example": 205
},
{
"section": "[extension] Tables",
"html": "<p>paragraph 1</p><table>\n<thead>\n<tr>\n<th>abc</th>\n<th>def</th>\n</tr>\n</thead>\n</table>",
"markdown": "paragraph 1\n| abc | def |\n| --- | --- |",
"example": 206
},
{
"section": "[extension] Tables",
"html": "<p>paragraph with <code>inline code</code></p><table>\n<thead>\n<tr>\n<th>abc</th>\n<th>def</th>\n</tr>\n</thead>\n</table>",
"markdown": "paragraph with `inline code`\n| abc | def |\n| --- | --- |",
"example": 207
},
{
"section": "[extension] Task list items",
"html": "<ul>\n<li><input disabled=\"\" type=\"checkbox\"> foo</li>\n<li><input checked=\"\" disabled=\"\" type=\"checkbox\"> bar</li>\n</ul>",
Expand Down
46 changes: 46 additions & 0 deletions test/unit/Lexer-spec.js
Expand Up @@ -204,6 +204,52 @@ lheading 2
});
});

it('table after para', () => {
expectTokens({
md: `
paragraph 1
| a | b |
|---|---|
| 1 | 2 |
`,
tokens: [
{
type: 'paragraph',
raw: 'paragraph 1',
text: 'paragraph 1',
tokens: [{ type: 'text', raw: 'paragraph 1', text: 'paragraph 1' }]
},
{
type: 'table',
align: [null, null],
raw: '| a | b |\n|---|---|\n| 1 | 2 |\n',
header: [
{
text: 'a',
tokens: [{ type: 'text', raw: 'a', text: 'a' }]
},
{
text: 'b',
tokens: [{ type: 'text', raw: 'b', text: 'b' }]
}
],
rows: [
[
{
text: '1',
tokens: [{ type: 'text', raw: '1', text: '1' }]
},
{
text: '2',
tokens: [{ type: 'text', raw: '2', text: '2' }]
}
]
]
}
]
});
});

it('align table', () => {
expectTokens({
md: `
Expand Down

0 comments on commit 7841ae6

Please sign in to comment.