Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

644 B
Raw Blame
package extensions

import (
	"testing"

	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
	"github.com/yuin/goldmark/ast"
	"github.com/yuin/goldmark/text"

	mast "github.com/usememos/memos/markdown/ast"
)

func TestReplaceMentionsInPaddedText(t *testing.T) {
	source := []byte("x@alice")
	paragraph := ast.NewParagraph()
	textNode := ast.NewTextSegment(text.NewSegmentPadding(1, len(source), 2))
	paragraph.AppendChild(paragraph, textNode)

	replaceMentionsInText(textNode, source)

	mention, ok := paragraph.LastChild().(*mast.MentionNode)
	require.True(t, ok)
	assert.Equal(t, "alice", string(mention.Username))
}