-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: grnd-alt <[email protected]>
- Loading branch information
Showing
3 changed files
with
54 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import Link from './../../marks/Link'; | ||
Check warning on line 1 in src/tests/marks/Link.spec.js
|
||
import { Underline } from '../../marks'; | ||
Check warning on line 2 in src/tests/marks/Link.spec.js
|
||
import { getExtensionField, getMarkRange } from '@tiptap/core' | ||
import { createCustomEditor } from '../helpers' | ||
Check warning on line 4 in src/tests/marks/Link.spec.js
|
||
import { Editor } from '@tiptap/vue-2'; | ||
|
||
describe('Link extension integrated in the editor', () => { | ||
|
||
it('should have link available in commands', () => { | ||
const editor = createCustomEditor({ | ||
content: '<p><a href="nextcloud.com">Te<u>s</u>t</a> HELLO WORLD</p>', | ||
extensions: [Link,Underline], | ||
}) | ||
expect(editor.commands).toHaveProperty('insertOrSetLink') | ||
}) | ||
|
||
it('should update link if anchor has mark', () => { | ||
const editor = createCustomEditor({ | ||
content: '<p><a href="nextcloud.com">Te<u>s</u>t</a> HELLO WORLD</p>', | ||
extensions: [Link,Underline], | ||
}) | ||
editor.commands.setTextSelection(3) | ||
editor.commands.insertOrSetLink('updated.de', {href: 'updated.de'}) | ||
expect(editor.getJSON()).toEqual({"content": [{"content": [{"marks": [{"attrs": {"href": "updated.de", "title": null}, "type": "link"}], "text": "updated.de", "type": "text"}, {"text": " HELLO WORLD", "type": "text"}], "type": "paragraph"}], "type": "doc"}) | ||
}) | ||
|
||
it('Should only update the anchor is on', () => { | ||
const editor = createCustomEditor({ | ||
content: '<p><a href="nextcloud.com">Test</a><a href="nextcloud.com">Test</a></p>', | ||
extensions: [Link], | ||
}) | ||
editor.commands.setTextSelection(3) | ||
editor.commands.insertOrSetLink('updated.de', {href: 'updated.de'}) | ||
expect(editor.getJSON()).toEqual({"content": [{"content": [{"marks": [{"attrs": {"href": "updated.de", "title": null}, "type": "link"}], "text": "updated.de", "type": "text"}, ], "type": "paragraph"}], "type": "doc"}) | ||
}) | ||
|
||
it('should insert new link if none at anchor', () => { | ||
const editor = createCustomEditor({ | ||
content: '<p><a href="nextcloud.com">Test</a> HELLO WORLD</p>', | ||
extensions: [Link], | ||
}) | ||
editor.commands.setTextSelection(10) | ||
expect(editor.getJSON()).toEqual({"content": [{"content": [{"marks": [{"attrs": {"href": "nextcloud.com", "title": null}, "type": "link"}], "text": "Test", "type": "text"}, {"text": " HELLO WORLD", "type": "text"}], "type": "paragraph"}], "type": "doc"}) | ||
}) | ||
|
||
|
||
}) |