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.
2019-06-01 04:38:35 +02:00
|
|
|
package component
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"gosrc.io/xmpp"
|
|
|
|
)
|
|
|
|
|
|
|
|
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-02 10:41:19 +02:00
|
|
|
p := c.sending(xmpp.IQ{})
|
2019-06-01 04:38:35 +02:00
|
|
|
assert.Nil(p)
|
|
|
|
|
|
|
|
// send by component host
|
2019-06-02 10:41:19 +02:00
|
|
|
p = c.sending(xmpp.Message{})
|
2019-06-01 04:38:35 +02:00
|
|
|
assert.NotNil(p)
|
|
|
|
msg := p.(xmpp.Message)
|
|
|
|
assert.Equal("example.org", msg.PacketAttrs.From)
|
|
|
|
|
|
|
|
// send by a user of component
|
2019-06-02 10:41:19 +02:00
|
|
|
p = c.sending(xmpp.Message{PacketAttrs: xmpp.PacketAttrs{From: "threemaid"}})
|
2019-06-01 04:38:35 +02:00
|
|
|
assert.NotNil(p)
|
|
|
|
msg = p.(xmpp.Message)
|
|
|
|
assert.Equal("threemaid@example.org", msg.PacketAttrs.From)
|
|
|
|
}
|