1- /* eslint-disable no-unused-expressions */
21/**
3- * @copyright Copyright (c) 2024 Max <max@nextcloud.com>
4- *
5- * @author Max <max@nextcloud.com>
6- *
7- * @license AGPL-3.0-or-later
8- *
9- * This program is free software: you can redistribute it and/or modify
10- * it under the terms of the GNU Affero General Public License as
11- * published by the Free Software Foundation, either version 3 of the
12- * License, or (at your option) any later version.
13- *
14- * This program is distributed in the hope that it will be useful,
15- * but WITHOUT ANY WARRANTY; without even the implied warranty of
16- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17- * GNU Affero General Public License for more details.
18- *
19- * You should have received a copy of the GNU Affero General Public License
20- * along with this program. If not, see <http://www.gnu.org/licenses/>.
21- *
2+ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
3+ * SPDX-License-Identifier: AGPL-3.0-or-later
224 */
235
246import Markdown from './../../../src/extensions/Markdown.js'
@@ -27,68 +9,37 @@ import { createCustomEditor } from './../../support/components.js'
279import { loadMarkdown , expectMarkdown } from '../nodes/helpers.js'
2810
2911describe ( 'Link marks' , { retries : 0 } , ( ) => {
30-
3112 const editor = createCustomEditor ( {
3213 content : '' ,
33- extensions : [
34- Markdown ,
35- Link ,
36- Italic ,
37- ] ,
14+ extensions : [ Markdown , Link , Italic ] ,
3815 } )
3916
4017 describe ( 'insertOrSetLink command' , { retries : 0 } , ( ) => {
41-
4218 it ( 'is available in commands' , ( ) => {
4319 expect ( editor . commands ) . to . have . property ( 'insertOrSetLink' )
4420 } )
4521
4622 it ( 'can run on normal paragraph' , ( ) => {
4723 prepareEditor ( 'hello\n' , 3 )
48- expect ( editor . can ( ) . insertOrSetLink ( ) ) . to . be . ok
24+ expect ( editor . can ( ) . insertOrSetLink ( ) ) . toBe ( true )
4925 } )
5026
5127 it ( 'will insert a link in a normal paragraph' , ( ) => {
5228 prepareEditor ( 'hello\n' , 3 )
53- editor . commands . insertOrSetLink ( 'https://nextcloud.com' , { href : 'https://nextcloud.com' } )
29+ editor . commands . insertOrSetLink ( 'https://nextcloud.com' , {
30+ href : 'https://nextcloud.com' ,
31+ } )
5432 expectMarkdown ( editor , 'he\n\n<https://nextcloud.com>\n\nllo' )
5533 } )
56-
5734 } )
5835
59- /**
60- * Expect a link in the editor.
61- */
62- function expectLink ( ) {
63- expect ( getParentNode ( ) . type . name ) . to . equal ( 'paragraph' )
64- expect ( getParentNode ( ) . attrs . href ) . to . equal ( 'https://nextcloud.com' )
65- expect ( getMark ( ) . attrs . href ) . to . equal ( 'https://nextcloud.com' )
66- }
67-
68- /**
69- *
70- */
71- function getParentNode ( ) {
72- const { state : { selection } } = editor
73- return selection . $head . parent
74- }
75-
7636 /**
7737 *
78- */
79- function getMark ( ) {
80- const { state : { selection } } = editor
81- console . info ( selection . $head )
82- return selection . $head . nodeAfter . marks [ 0 ]
83- }
84-
85- /**
86- *
87- * @param input
38+ * @param {* } input markdown content
39+ * @param {* } position cursor pos
8840 */
8941 function prepareEditor ( input , position = 1 ) {
9042 loadMarkdown ( editor , input )
91- editor . commands . setTextSelection ( position )
43+ editor . commands . setTextSelection ( position )
9244 }
93-
9445} )
0 commit comments