// Vikunja is a to-do list application to facilitate your life. // Copyright 2018-present Vikunja and contributors. All rights reserved. // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . package richtext import ( "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestHTMLToMarkdown_TipTap(t *testing.T) { tests := []struct { name string html string want string }{ { name: "mention uses data-id and drops label", html: `

@differentlabel

`, want: "@actualuser", }, { name: "empty mention keeps following space", html: `

hello

`, want: "@frederick hello", }, { name: "mention next to punctuation stays intact", html: `

cc @jane, please review

`, want: "cc @jane, please review", }, { name: "multiple mentions in one block", html: `

ping @user1 and @user2

`, want: "ping @user1 and @user2", }, { name: "mention without data-id keeps inner text", html: `

@someuser hi

`, want: "@someuser hi", }, { name: "tiptap task list checked and unchecked", html: ``, want: "- [x] done item\n- [ ] todo item", }, { name: "task list bare data-checked form", html: ``, want: "- [ ] Item 1", }, { name: "nested task list items", html: ``, want: "- [ ] parent\n \n - [x] child", }, { name: "mention inside task list item", html: ``, want: "- [ ] ask @bob", }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { got, err := HTMLToMarkdown(tt.html) require.NoError(t, err) assert.Equal(t, tt.want, got) }) } }