Spaces:
Paused
Paused
File size: 1,331 Bytes
83a59ca | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | package requests
import (
"testing"
"github.com/NdoleStudio/httpsms/pkg/entities"
"github.com/stretchr/testify/assert"
)
func TestMessageThreadIndex_ToGetParams_WithContactsTrue(t *testing.T) {
input := (&MessageThreadIndex{Owner: "+18005550199", Contacts: " true "}).Sanitize()
params := input.ToGetParams(entities.UserID("user-id"))
assert.Equal(t, "true", input.Contacts)
assert.True(t, params.WithContacts)
}
func TestMessageThreadIndex_ToGetParams_WithContactsFalse(t *testing.T) {
input := (&MessageThreadIndex{Owner: "+18005550199", Contacts: "0"}).Sanitize()
params := input.ToGetParams(entities.UserID("user-id"))
assert.Equal(t, "false", input.Contacts)
assert.False(t, params.WithContacts)
}
func TestMessageThreadIndex_ToGetParams_WithContactsDefaultsFalse(t *testing.T) {
input := (&MessageThreadIndex{Owner: "+18005550199"}).Sanitize()
params := input.ToGetParams(entities.UserID("user-id"))
assert.Equal(t, "false", input.Contacts)
assert.False(t, params.WithContacts)
}
func TestMessageThreadIndex_ToGetParams_WithContactsInvalidNormalizesFalse(t *testing.T) {
input := (&MessageThreadIndex{Owner: "+18005550199", Contacts: "definitely"}).Sanitize()
params := input.ToGetParams(entities.UserID("user-id"))
assert.Equal(t, "false", input.Contacts)
assert.False(t, params.WithContacts)
}
|