Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/content_editor/extensions/image_spec.js')
-rw-r--r--spec/frontend/content_editor/extensions/image_spec.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/frontend/content_editor/extensions/image_spec.js b/spec/frontend/content_editor/extensions/image_spec.js
new file mode 100644
index 00000000000..256f7bad309
--- /dev/null
+++ b/spec/frontend/content_editor/extensions/image_spec.js
@@ -0,0 +1,41 @@
+import Image from '~/content_editor/extensions/image';
+import { createTestEditor, createDocBuilder } from '../test_utils';
+
+describe('content_editor/extensions/image', () => {
+ let tiptapEditor;
+ let doc;
+ let p;
+ let image;
+
+ beforeEach(() => {
+ tiptapEditor = createTestEditor({ extensions: [Image] });
+
+ ({
+ builders: { doc, p, image },
+ } = createDocBuilder({
+ tiptapEditor,
+ names: {
+ image: { nodeType: Image.name },
+ },
+ }));
+ });
+
+ it('adds data-canonical-src attribute when rendering to HTML', () => {
+ const initialDoc = doc(
+ p(
+ image({
+ canonicalSrc: 'uploads/image.jpg',
+ src: '/-/wikis/uploads/image.jpg',
+ alt: 'image',
+ title: 'this is an image',
+ }),
+ ),
+ );
+
+ tiptapEditor.commands.setContent(initialDoc.toJSON());
+
+ expect(tiptapEditor.getHTML()).toEqual(
+ '<p><img src="/-/wikis/uploads/image.jpg" alt="image" title="this is an image" data-canonical-src="uploads/image.jpg"></p>',
+ );
+ });
+});