Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
mjbvz committed Apr 2, 2024
1 parent 97284fa commit bbceaed
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,33 @@ describe('Markdown It Front Matter', () => {

assert.equal(foundFrontmatter, 'x: 1\n---');
});

it('Should set correct map for front-matter token', () => {
{
const tokens = md.parse([
'----',
'x: 1',
'---',
'# Head'
].join('\n'));

assert.strictEqual(tokens[0].type, 'front_matter');
assert.deepStrictEqual(tokens[0].map, [0, 4]);
}
{
const tokens = md.parse([
'----',
'title: Associative arrays',
'people:',
' name: John Smith',
' age: 33',
'morePeople: { name: Grace Jones, age: 21 }',
'---',
'# Head'
].join('\n'));

assert.strictEqual(tokens[0].type, 'front_matter');
assert.deepStrictEqual(tokens[0].map, [0, 8]);
}
});
});

0 comments on commit bbceaed

Please sign in to comment.