Split into category packages; module github.com/ZacharyZhang-NY/MujicaUI

This commit is contained in:
ZacharyZhang-NY committed 2026-10-05 16:18:48 -04:00
1 parent 5a7e921c7e
commit 22b53e9e9e
1822 files changed
+24568 -21314

No files matched your search

+55
View File
@@ -0,0 +1,55 @@
package chat
import (
"slices"
"strings"
"testing"
"github.com/egoist/mygo/ui"
"github.com/ZacharyZhang-NY/MujicaUI/core"
)
func TestDragDropOverlayIdleShowsContentOnly(t *testing.T) {
tt := ui.NewTester(func(c *ui.Context) {
core.Use(c, core.Settings{})
DragDropOverlay(c, DragDropOverlayOptions{}, func() { ui.Text(c, "Chat") })
}, 300, 200)
if !tt.HasText("Chat") || tt.HasText("Drop files to attach") {
t.Fatalf("idle overlay: %q", tt.Texts())
}
}
func TestDragDropOverlaySplitsByAccept(t *testing.T) {
images := func(p string) bool { return strings.HasSuffix(p, ".png") }
ok, no := dragDropSplit([]string{"/a.png", "/b.exe", "/c.png"}, images)
if !slices.Equal(ok, []string{"/a.png", "/c.png"}) || !slices.Equal(no, []string{"/b.exe"}) {
t.Fatalf("ok %v no %v", ok, no)
}
ok, no = dragDropSplit([]string{"/b.exe"}, nil)
if len(ok) != 1 || no != nil {
t.Fatalf("nil accept: ok %v no %v", ok, no)
}
}
func TestDragDropOverlayNeedsContent(t *testing.T) {
defer func() {
if recover() == nil {
t.Fatal("no panic without content")
}
}()
ui.NewTester(func(c *ui.Context) {
core.Use(c, core.Settings{})
DragDropOverlay(c, DragDropOverlayOptions{}, nil)
}, 100, 100)
}
// TestDragDropOverlaySnapshot captures the active drop mask.
func TestDragDropOverlaySnapshot(t *testing.T) {
snapshot(t, "drag_drop_overlay", 420, 220, func(c *ui.Context) {
ui.Box(c).Fill().Padding(12).Children(func() {
ui.Text(c, "A conversation sits under the mask.")
dragDropMask(c, core.Msg(c, "drag_drop_overlay.hint"))
})
})
}