This repository has been archived on 2020-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
thrempp/component/send_test.go

31 lines
621 B
Go
Raw Normal View History

2019-06-01 04:38:35 +02:00
package component
import (
"testing"
"github.com/stretchr/testify/assert"
2019-06-28 03:03:38 +02:00
"gosrc.io/xmpp/stanza"
2019-06-01 04:38:35 +02:00
)
func TestSend(t *testing.T) {
assert := assert.New(t)
2019-06-06 21:20:51 +02:00
c := Config{Host: "example.org", XMPPDebug: true}
2019-06-01 04:38:35 +02:00
// ignoring packet
2019-06-28 03:03:38 +02:00
p := c.sending(stanza.IQ{})
2019-06-01 04:38:35 +02:00
assert.Nil(p)
// send by component host
2019-06-28 03:03:38 +02:00
p = c.sending(stanza.Message{})
2019-06-01 04:38:35 +02:00
assert.NotNil(p)
2019-06-28 03:03:38 +02:00
msg := p.(stanza.Message)
assert.Equal("example.org", msg.From)
2019-06-01 04:38:35 +02:00
// send by a user of component
2019-06-28 03:03:38 +02:00
p = c.sending(stanza.Message{Attrs: stanza.Attrs{From: "threemaid"}})
2019-06-01 04:38:35 +02:00
assert.NotNil(p)
2019-06-28 03:03:38 +02:00
msg = p.(stanza.Message)
assert.Equal("threemaid@example.org", msg.From)
2019-06-01 04:38:35 +02:00
}