debian-mirror-gitlab/spec/frontend/content_editor/extensions/image_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

42 lines
1 KiB
JavaScript
Raw Normal View History

2022-03-02 08:16:31 +05:30
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>',
);
});
});