update QoL and ai integration
This commit is contained in:
@@ -4,7 +4,9 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
"github.com/charmbracelet/x/ansi"
|
||||
"github.com/muesli/termenv"
|
||||
)
|
||||
|
||||
func TestCommentMarkdownDistinguishesQuoteAndReply(t *testing.T) {
|
||||
@@ -109,3 +111,40 @@ func TestCommentMarkdownStaysWithinRequestedWidth(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCommentMarkdownHighlightsContributorMentions(t *testing.T) {
|
||||
defer applyTheme("dark")
|
||||
if err := applyTheme("dark"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
previousProfile := lipgloss.ColorProfile()
|
||||
lipgloss.SetColorProfile(termenv.TrueColor)
|
||||
t.Cleanup(func() { lipgloss.SetColorProfile(previousProfile) })
|
||||
rendered := strings.Join(renderCommentMarkdown(
|
||||
"Ask @pablu and @other-contributor, then continue with **important text**.", 80,
|
||||
), "\n")
|
||||
for _, login := range []string{"pablu", "other-contributor"} {
|
||||
mention := "@" + login
|
||||
if !strings.Contains(rendered, authorStyle(login).Render(mention)) {
|
||||
t.Fatalf("%s does not use its deterministic author style:\n%q", mention, rendered)
|
||||
}
|
||||
}
|
||||
if plain := strings.TrimSpace(ansi.Strip(rendered)); plain !=
|
||||
"Ask @pablu and @other-contributor, then continue with important text." {
|
||||
t.Fatalf("mention highlighting changed rendered text: %q", plain)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCommentMarkdownDoesNotHighlightEmailAddresses(t *testing.T) {
|
||||
defer applyTheme("dark")
|
||||
if err := applyTheme("dark"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
previousProfile := lipgloss.ColorProfile()
|
||||
lipgloss.SetColorProfile(termenv.TrueColor)
|
||||
t.Cleanup(func() { lipgloss.SetColorProfile(previousProfile) })
|
||||
rendered := highlightRenderedMentions("Email dev@example.com, then ask @example.")
|
||||
if count := strings.Count(rendered, authorStyle("example").Render("@example")); count != 1 {
|
||||
t.Fatalf("highlighted @example count = %d, want 1: %q", count, rendered)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user