Split into category packages; module github.com/ZacharyZhang-NY/MujicaUI
This commit is contained in:
1822 files changed
+24568
-21314
No files matched your search
@@ -0,0 +1,49 @@
|
||||
package messaging
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/egoist/mygo/ui"
|
||||
|
||||
"github.com/ZacharyZhang-NY/MujicaUI/core"
|
||||
)
|
||||
|
||||
func TestMessagingLargeListsBounded(t *testing.T) {
|
||||
const count = 100000
|
||||
channels := make([]Channel, count)
|
||||
pins := make([]ChatEntry, count)
|
||||
for i := range count {
|
||||
channels[i] = Channel{ID: fmt.Sprint(i), Name: fmt.Sprint("Channel ", i)}
|
||||
pins[i] = ChatEntry{ID: fmt.Sprint(i), Author: "Author", Text: fmt.Sprint("Pinned ", i)}
|
||||
}
|
||||
for _, name := range []string{"channels", "pins"} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
selected := ""
|
||||
groups := []ChannelGroup{{ID: "g", Title: "Group", Channels: channels}}
|
||||
tt := ui.NewTester(func(c *ui.Context) {
|
||||
core.Use(c, core.Settings{})
|
||||
ui.Column(c).Height(280).Children(func() {
|
||||
if name == "channels" {
|
||||
ChannelList(c, &selected, groups, ChannelListOptions{Height: 240})
|
||||
} else {
|
||||
PinnedMessages(c, pins, PinnedMessagesOptions{Height: 240})
|
||||
}
|
||||
})
|
||||
}, 400, 300)
|
||||
prefix := "Channel "
|
||||
if name == "pins" {
|
||||
prefix = "Pinned "
|
||||
}
|
||||
n := 0
|
||||
for _, text := range tt.Texts() {
|
||||
if len(text) >= len(prefix) && text[:len(prefix)] == prefix {
|
||||
n++
|
||||
}
|
||||
}
|
||||
if n == 0 || n > 60 {
|
||||
t.Fatalf("built %d of %d", n, count)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user