Skip to content

Commit

Permalink
test: improve block anchor spec
Browse files Browse the repository at this point in the history
  • Loading branch information
main-kun authored and moki committed Nov 30, 2023
1 parent cb42b3f commit 8d9712e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions test/block-anchor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,18 @@ describe('block-anchor', function () {
expect(transformYfm('{%anchor my-anchor%}')).toBe('<a id="my-anchor"></a>');
});
it('does not consume things it should not', () => {
expect(transformYfm('# Heading \n {%anchor my-anchor%} \n # Other heading')).toContain(
'Other heading',
expect(transformYfm('# Heading \n {%anchor my-anchor%} \n # Other heading')).toEqual(
'<h1 id="heading"><a href="#heading" class="yfm-anchor" aria-hidden="true">' +
'<span class="visually-hidden">Heading</span></a>Heading</h1>\n' +
'<a id="my-anchor"></a><h1 id="other-heading">' +
'<a href="#other-heading" class="yfm-anchor" aria-hidden="true">' +
'<span class="visually-hidden">Other heading</span></a>Other heading</h1>\n',
);
});

it('does not match an anchor if theres something right in front of it', () => {
expect(transformYfm('${%anchor my-anchor} Content')).toEqual(
'<p>${%anchor my-anchor} Content</p>\n',
);
});
});
Expand Down

0 comments on commit 8d9712e

Please sign in to comment.