Skip to content

Commit

Permalink
add more some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wxiaoguang committed Nov 23, 2024
1 parent ef1af4a commit ecd3673
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions models/renderhelper/repo_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,20 @@ func TestRepoFile(t *testing.T) {
<a href="/user2/repo1/media/commit/1234/image" target="_blank" rel="nofollow noopener"><img src="/user2/repo1/media/commit/1234/image" alt="/image"/></a></p>
`, rendered)
})

t.Run("WithCurrentRefPathByTag", func(t *testing.T) {
rctx := NewRenderContextRepoFile(context.Background(), repo1, RepoFileOptions{
CurrentRefPath: "/commit/1234",
CurrentTreePath: "my-dir",
}).
WithMarkupType(markdown.MarkupName)
rendered, err := markup.RenderString(rctx, `
<img src="LINK">
<video src="LINK">
`)
assert.NoError(t, err)
assert.Equal(t, `<a href="/user2/repo1/media/commit/1234/my-dir/LINK/" target="_blank" rel="nofollow noopener"><img src="/user2/repo1/media/commit/1234/my-dir/LINK/"/></a>
<video src="/user2/repo1/media/commit/1234/my-dir/LINK/">
</video>`, rendered)
})
}

0 comments on commit ecd3673

Please sign in to comment.