Skip to content

Commit

Permalink
Add tests, do not append source if disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
lsirivong committed Apr 27, 2023
1 parent 65570f5 commit 15a66c9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/formats/autolink.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ module.exports = {
add: function(node, value, dom) {
if (!value.disabled) {
node = addLink(node, value.href, dom);
}

if (value.source) {
node.dataset.source = value.source;
if (value.source) {
node.dataset.source = value.source;
}
}

return node;
Expand Down
12 changes: 11 additions & 1 deletion test/server/to_public_html.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,21 @@ describe('to_public_html', function() {
{ insert: 'Star Wars', attributes: { autolink: { id: 1, href: 'http://starwars.com/', disabled: false } } },
{ insert: ' but ' },
{ insert: 'Star Trek', attributes: { autolink: { id: 2, href: 'http://startrek.com/', disabled: true } } },
{ insert: ' is just okay!' }
{ insert: ' is just ' },
{ insert: 'okay!', attributes: { autolink: { id: 3, href: 'http://okay.com/', disabled: true, source: 'name-of-backlinker' } } }
] },
html:
'<p>I like <a href="http://starwars.com/">Star Wars</a> but Star Trek is just okay!</p>'
},
{
message: 'renders autolink source data attribute',
delta: { ops: [
{ insert: 'Vox Media', attributes: { autolink: { id: 1, href: 'http://product.voxmedia.com/', disabled: false, source: 'name-of-backlinker' } } },
{ insert: ' is a pretty great place.' }
] },
html:
'<p><a href="http://product.voxmedia.com/" data-source="name-of-backlinker">Vox Media</a> is a pretty great place.</p>'
},
{
message: 'converts to <br> tags',
delta: { ops: [
Expand Down

0 comments on commit 15a66c9

Please sign in to comment.