0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Updated tests for new mobiledoc output

refs f6e7dac7bb
This commit is contained in:
Kevin Ansfield 2021-02-16 11:42:07 +00:00
parent f6e7dac7bb
commit 77f75808a7
2 changed files with 29 additions and 2 deletions

View file

@ -1145,6 +1145,7 @@ describe('Integration: Importer', function () {
slug: 'post1',
mobiledoc: JSON.stringify({
version: '0.3.1',
ghostVersion: '3.0', // 3.0 is when ghostVersion was introduced
markups: [],
atoms: [],
cards: [
@ -1186,6 +1187,7 @@ describe('Integration: Importer', function () {
slug: 'post1',
mobiledoc: JSON.stringify({
version: '0.3.1',
ghostVersion: '3.0', // 3.0 is when ghostVersion was introduced
markups: [],
atoms: [],
cards: [
@ -1207,6 +1209,7 @@ describe('Integration: Importer', function () {
slug: 'post2',
mobiledoc: JSON.stringify({
version: '0.3.1',
ghostVersion: '3.0',
markups: [],
atoms: [],
cards: [
@ -1541,7 +1544,7 @@ describe('1.0', function () {
const posts = result[0].data.map(model => model.toJSON(options));
posts.length.should.eql(1);
posts[0].html.should.eql('<!--kg-card-begin: markdown--><h1 id="thisismypostcontent">This is my post content</h1>\n<!--kg-card-end: markdown-->');
posts[0].html.should.eql('<!--kg-card-begin: markdown--><h1 id="this-is-my-post-content">This is my post content</h1>\n<!--kg-card-end: markdown-->');
posts[0].mobiledoc.should.eql(exportData.data.posts[0].mobiledoc);
});
});
@ -1606,7 +1609,7 @@ describe('1.0', function () {
posts[0].html.should.eql('<!--kg-card-begin: markdown--><h2 id="postcontent">Post Content</h2>\n<!--kg-card-end: markdown--><figure class="kg-card kg-image-card kg-width-not-wide"><img src="source2" class="kg-image" alt></figure>');
posts[1].mobiledoc.should.eql('{"version":"0.3.1","markups":[],"atoms":[],"cards":[["image",{"src":"source","cardWidth":"wide"}],["markdown",{"markdown":"# Post Content"}]],"sections":[[10,0],[10,1]]}');
posts[1].html.should.eql('<figure class="kg-card kg-image-card kg-width-wide"><img src="source" class="kg-image" alt></figure><!--kg-card-begin: markdown--><h1 id="postcontent">Post Content</h1>\n<!--kg-card-end: markdown-->');
posts[1].html.should.eql('<figure class="kg-card kg-image-card kg-width-wide"><img src="source" class="kg-image" alt></figure><!--kg-card-begin: markdown--><h1 id="post-content">Post Content</h1>\n<!--kg-card-end: markdown-->');
});
});
});

View file

@ -22,6 +22,7 @@ describe('lib/mobiledoc', function () {
it('renders all default cards and atoms', function () {
let mobiledoc = {
version: '0.3.1',
ghostVersion: '0.3',
atoms: [
['soft-return', '', {}]
],
@ -80,6 +81,29 @@ describe('lib/mobiledoc', function () {
.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" alt srcset="/content/images/size/w600/2018/04/NatGeo06.jpg 600w, /content/images/size/w1000/2018/04/NatGeo06.jpg 1000w, /content/images/size/w1600/2018/04/NatGeo06.jpg 1600w, /content/images/size/w2400/2018/04/NatGeo06.jpg 2400w" sizes="(min-width: 1200px) 1200px"><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 class="kg-gallery-row"><div class="kg-gallery-image"><img src="/content/images/test.png" width="1000" height="500" alt srcset="/content/images/size/w600/test.png 600w, /content/images/test.png 1000w" sizes="(min-width: 720px) 720px"></div></div></div></figure>');
});
it('renders according to ghostVersion', function () {
let mobiledoc = {
version: '0.3.1',
ghostVersion: '4.0',
atoms: [],
cards: [
['markdown', {
markdown: '# Header One'
}]
],
markups: [],
sections: [
[10, 0],
[1, 'h2', [
[0, [], 0, 'Héader Two']]
]
]
};
mobiledocLib.mobiledocHtmlRenderer.render(mobiledoc)
.should.eql('<!--kg-card-begin: markdown--><h1 id="header-one">Header One</h1>\n<!--kg-card-end: markdown--><h2 id="h%C3%A9ader-two">Héader Two</h2>');
});
it('respects srcsets config', function () {
configUtils.set('imageOptimization:srcsets', false);