53 lines
1.7 KiB
Go
53 lines
1.7 KiB
Go
package adapter
|
|
|
|
import "testing"
|
|
|
|
func TestCapabilitiesNormalizeFillsZeroNumerics(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
caps := Capabilities{Image: true, Proactive: true}.Normalize()
|
|
|
|
if caps.MaxMessageLength != defaultMaxMessageLength {
|
|
t.Errorf("MaxMessageLength = %d, want %d", caps.MaxMessageLength, defaultMaxMessageLength)
|
|
}
|
|
if caps.RecommendBurstMax != defaultRecommendBurstMax {
|
|
t.Errorf("RecommendBurstMax = %d, want %d", caps.RecommendBurstMax, defaultRecommendBurstMax)
|
|
}
|
|
// Boolean fields must be preserved, not overwritten by normalization.
|
|
if !caps.Image || !caps.Proactive {
|
|
t.Errorf("booleans changed by Normalize: %+v", caps)
|
|
}
|
|
}
|
|
|
|
func TestCapabilitiesNormalizePreservesExplicit(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
caps := Capabilities{MaxMessageLength: 100, RecommendBurstMax: 5}.Normalize()
|
|
|
|
if caps.MaxMessageLength != 100 {
|
|
t.Errorf("MaxMessageLength = %d, want 100 (explicit preserved)", caps.MaxMessageLength)
|
|
}
|
|
if caps.RecommendBurstMax != 5 {
|
|
t.Errorf("RecommendBurstMax = %d, want 5 (explicit preserved)", caps.RecommendBurstMax)
|
|
}
|
|
}
|
|
|
|
func TestDefaultCapabilities(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
caps := DefaultCapabilities()
|
|
|
|
if caps.MaxMessageLength != defaultMaxMessageLength {
|
|
t.Errorf("MaxMessageLength = %d, want %d", caps.MaxMessageLength, defaultMaxMessageLength)
|
|
}
|
|
if !caps.Markdown || !caps.Image {
|
|
t.Errorf("expected markdown+image by default, got %+v", caps)
|
|
}
|
|
if caps.Voice || caps.Reaction || caps.TypingHint || caps.Proactive {
|
|
t.Errorf("expected rich/proactive features off by default, got %+v", caps)
|
|
}
|
|
if caps.RecommendBurstMax != defaultRecommendBurstMax {
|
|
t.Errorf("RecommendBurstMax = %d, want %d", caps.RecommendBurstMax, defaultRecommendBurstMax)
|
|
}
|
|
}
|