mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Koenig - Fixed empty HTML card rendering undefined
refs https://github.com/TryGhost/Ghost/issues/9623 - add tests for undefined payloads in container cards - add guard for undefined payload in html card
This commit is contained in:
parent
d10cb5cb6b
commit
367c5b9639
3 changed files with 33 additions and 0 deletions
|
@ -2,6 +2,10 @@ module.exports = {
|
|||
name: 'html',
|
||||
type: 'dom',
|
||||
render(opts) {
|
||||
if (!opts.payload.html) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// use the SimpleDOM document to create a raw HTML section.
|
||||
// avoids parsing/rendering of potentially broken or unsupported HTML
|
||||
return opts.env.dom.createRawHTMLSection(opts.payload.html);
|
||||
|
|
|
@ -44,4 +44,17 @@ describe('HTML card', function () {
|
|||
|
||||
serializer.serialize(card.render(opts)).should.match('<h1>HEADING<');
|
||||
});
|
||||
|
||||
it('Renders nothing when payload is undefined', function () {
|
||||
let opts = {
|
||||
env: {
|
||||
dom: new SimpleDom.Document()
|
||||
},
|
||||
payload: {
|
||||
html: undefined
|
||||
}
|
||||
};
|
||||
|
||||
serializer.serialize(card.render(opts)).should.match('');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -72,5 +72,21 @@ describe('Markdown card', function () {
|
|||
|
||||
serializer.serialize(card.render(opts)).should.match('<h1 id="heading">HEADING</h1>\n<h2>Heading 2>');
|
||||
});
|
||||
|
||||
it('Renders nothing when payload is undefined', function () {
|
||||
let opts = {
|
||||
env: {
|
||||
dom: new SimpleDom.Document()
|
||||
},
|
||||
payload: {
|
||||
markdown: undefined
|
||||
},
|
||||
options: {
|
||||
version: 2
|
||||
}
|
||||
};
|
||||
|
||||
serializer.serialize(card.render(opts)).should.match('');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue