52 рядки
1.2 KiB
Go
52 рядки
1.2 KiB
Go
package share
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"git.entityseven.com/rilaxik/pllist/internal/domain"
|
|
"git.entityseven.com/rilaxik/pllist/internal/service"
|
|
)
|
|
|
|
func TestSharesTextShowsActiveAndPendingShares(t *testing.T) {
|
|
list := service.ShareList{
|
|
Access: domain.Access{List: domain.List{ID: 1, Title: "Groceries"}},
|
|
Shares: []domain.Share{
|
|
{ID: 1, Username: "alice_1", Role: domain.RoleEditor},
|
|
{ID: 2, TelegramID: 12345, Role: domain.RoleReader, Pending: true},
|
|
},
|
|
}
|
|
|
|
text := sharesText(list)
|
|
for _, want := range []string{
|
|
"<b>Shares: Groceries</b>",
|
|
"@alice_1 — editor",
|
|
"ID 12345 — reader (pending)",
|
|
"Pending shares activate",
|
|
} {
|
|
if !strings.Contains(text, want) {
|
|
t.Fatalf("sharesText() = %q, missing %q", text, want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestShareDetailText(t *testing.T) {
|
|
list := service.ShareList{
|
|
Access: domain.Access{List: domain.List{ID: 1, Title: "Groceries"}},
|
|
}
|
|
text := shareDetailText(list, domain.Share{
|
|
ID: 1, Username: "alice_1", Role: domain.RoleReader, Pending: true,
|
|
})
|
|
|
|
for _, want := range []string{
|
|
"<b>Share · Groceries</b>",
|
|
"User: @alice_1",
|
|
"Role: reader",
|
|
"Status: pending",
|
|
} {
|
|
if !strings.Contains(text, want) {
|
|
t.Fatalf("shareDetailText() = %q, missing %q", text, want)
|
|
}
|
|
}
|
|
}
|