diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-20 00:08:19 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-20 00:08:19 +0300 |
commit | 13aa07d3396762695fe47b0898dd346854b3993c (patch) | |
tree | 59e0bb92da3c82ae26a0609f24dd991109d2cfde /spec/frontend/content_editor | |
parent | d4e22f4ade1ce4dfd54f4d1740f074b2be441705 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/content_editor')
-rw-r--r-- | spec/frontend/content_editor/services/markdown_serializer_spec.js | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/spec/frontend/content_editor/services/markdown_serializer_spec.js b/spec/frontend/content_editor/services/markdown_serializer_spec.js index a29678ff1bc..2cd8b8a0d6f 100644 --- a/spec/frontend/content_editor/services/markdown_serializer_spec.js +++ b/spec/frontend/content_editor/services/markdown_serializer_spec.js @@ -318,7 +318,7 @@ var y = 10; expect( serialize( codeBlock( - { language: 'json' }, + { language: 'json', langParams: '' }, 'this is not really json but just trying out whether this case works or not', ), ), @@ -331,6 +331,23 @@ this is not really json but just trying out whether this case works or not ); }); + it('correctly serializes a code block with language parameters', () => { + expect( + serialize( + codeBlock( + { language: 'json', langParams: 'table' }, + 'this is not really json:table but just trying out whether this case works or not', + ), + ), + ).toBe( + ` +\`\`\`json:table +this is not really json:table but just trying out whether this case works or not +\`\`\` + `.trim(), + ); + }); + it('correctly serializes emoji', () => { expect(serialize(paragraph(emoji({ name: 'dog' })))).toBe(':dog:'); }); @@ -380,6 +397,26 @@ this is not really json but just trying out whether this case works or not ); }); + it.each` + width | height | outputAttributes + ${300} | ${undefined} | ${'width=300'} + ${undefined} | ${300} | ${'height=300'} + ${300} | ${300} | ${'width=300 height=300'} + ${'300%'} | ${'300px'} | ${'width="300%" height="300px"'} + `( + 'correctly serializes an image with width and height attributes', + ({ width, height, outputAttributes }) => { + const imageAttrs = { src: 'img.jpg', alt: 'foo bar' }; + + if (width) imageAttrs.width = width; + if (height) imageAttrs.height = height; + + expect(serialize(paragraph(image(imageAttrs)))).toBe( + `![foo bar](img.jpg){${outputAttributes}}`, + ); + }, + ); + it('does not serialize an image when src and canonicalSrc are empty', () => { expect(serialize(paragraph(image({})))).toBe(''); }); |