mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
b37ac8ef1f
no issue - moved `mobiledoc.renderers.mobiledocHtmlRenderer` to `mobiledoc.mobiledocHtmlRenderer` so that it's easier for the getter to access the parent objects getters - removed all tests and dependencies that now live in @tryghost/mobiledoc-dom-renderer - kept the `mobiledocHtmlRenderer` test because that's testing that we've correctly wired up our cards and atoms and the output is what we expect
73 lines
2.9 KiB
JavaScript
73 lines
2.9 KiB
JavaScript
const should = require('should');
|
|
const configUtils = require('../../utils/configUtils');
|
|
const mobiledocLib = require('../../../core/server/lib/mobiledoc');
|
|
|
|
describe('lib/mobiledoc', function () {
|
|
beforeEach(function () {
|
|
configUtils.set('url', 'https://example.com');
|
|
});
|
|
|
|
afterEach(function () {
|
|
configUtils.restore();
|
|
});
|
|
|
|
describe('mobiledocHtmlRenderer', function () {
|
|
it('renders all default cards and atoms', function () {
|
|
let mobiledoc = {
|
|
version: '0.3.1',
|
|
atoms: [
|
|
['soft-return', '', {}]
|
|
],
|
|
cards: [
|
|
['markdown', {
|
|
markdown: '# Markdown card\nSome markdown'
|
|
}],
|
|
['hr', {}],
|
|
['image', {
|
|
cardWidth: 'wide',
|
|
src: '/content/images/2018/04/NatGeo06.jpg',
|
|
caption: 'Birdies'
|
|
}],
|
|
['html', {
|
|
html: '<h2>HTML card</h2>\n<div><p>Some HTML</p></div>'
|
|
}],
|
|
['embed', {
|
|
html: '<h2>Embed card</h2>'
|
|
}],
|
|
['gallery', {
|
|
images: [{
|
|
fileName: 'test.png',
|
|
src: '/test.png',
|
|
width: 1000,
|
|
height: 500
|
|
}]
|
|
}]
|
|
],
|
|
markups: [],
|
|
sections: [
|
|
[1, 'p', [
|
|
[0, [], 0, 'One'],
|
|
[1, [], 0, 0],
|
|
[0, [], 0, 'Two']
|
|
]],
|
|
[10, 0],
|
|
[1, 'p', [
|
|
[0, [], 0, 'Three']
|
|
]],
|
|
[10, 1],
|
|
[10, 2],
|
|
[1, 'p', [
|
|
[0, [], 0, 'Four']
|
|
]],
|
|
[10, 3],
|
|
[10, 4],
|
|
[10, 5],
|
|
[1, 'p', []]
|
|
]
|
|
};
|
|
|
|
mobiledocLib.mobiledocHtmlRenderer.render(mobiledoc)
|
|
.should.eql('<p>One<br>Two</p><!--kg-card-begin: markdown--><h1 id="markdowncard">Markdown card</h1>\n<p>Some markdown</p>\n<!--kg-card-end: markdown--><p>Three</p><hr><figure class="kg-card kg-image-card kg-width-wide kg-card-hascaption"><img src="/content/images/2018/04/NatGeo06.jpg" class="kg-image"><figcaption>Birdies</figcaption></figure><p>Four</p><!--kg-card-begin: html--><h2>HTML card</h2>\n<div><p>Some HTML</p></div><!--kg-card-end: html--><figure class="kg-card kg-embed-card"><h2>Embed card</h2></figure><figure class="kg-card kg-gallery-card kg-width-wide"><div class="kg-gallery-container"></div></figure>');
|
|
});
|
|
});
|
|
});
|