mirror of
https://github.com/usememos/memos.git
synced 2025-01-10 14:22:07 +08:00
48 lines
826 B
Go
48 lines
826 B
Go
|
package parser
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/stretchr/testify/require"
|
||
|
|
||
|
"github.com/usememos/memos/plugin/gomark/ast"
|
||
|
"github.com/usememos/memos/plugin/gomark/parser/tokenizer"
|
||
|
)
|
||
|
|
||
|
func TestBlockquoteParser(t *testing.T) {
|
||
|
tests := []struct {
|
||
|
text string
|
||
|
blockquote ast.Node
|
||
|
}{
|
||
|
{
|
||
|
text: "> Hello world",
|
||
|
blockquote: &ast.Blockquote{
|
||
|
Children: []ast.Node{
|
||
|
&ast.Text{
|
||
|
Content: "Hello world",
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
{
|
||
|
text: "> Hello\nworld",
|
||
|
blockquote: &ast.Blockquote{
|
||
|
Children: []ast.Node{
|
||
|
&ast.Text{
|
||
|
Content: "Hello",
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
{
|
||
|
text: ">Hello\nworld",
|
||
|
blockquote: nil,
|
||
|
},
|
||
|
}
|
||
|
|
||
|
for _, test := range tests {
|
||
|
tokens := tokenizer.Tokenize(test.text)
|
||
|
require.Equal(t, test.blockquote, NewBlockquoteParser().Parse(tokens))
|
||
|
}
|
||
|
}
|