Add helpers to access full / bare jid as string

This commit is contained in:
Mickael Remond
2019-06-07 16:25:18 +02:00
parent ae153e1ee5
commit eb2b506e3b
2 changed files with 36 additions and 0 deletions

View File

@@ -59,3 +59,28 @@ func TestIncorrectJids(t *testing.T) {
}
}
}
func TestFull(t *testing.T) {
jid := "test@domain.com/my resource"
parsedJid, err := NewJid(jid)
if err != nil {
t.Errorf("could not parse jid: %v", err)
}
fullJid := parsedJid.Full()
if fullJid != jid {
t.Errorf("incorrect full jid: %s", fullJid)
}
}
func TestBare(t *testing.T) {
jid := "test@domain.com"
fullJid := jid + "/my resource"
parsedJid, err := NewJid(fullJid)
if err != nil {
t.Errorf("could not parse jid: %v", err)
}
bareJid := parsedJid.Bare()
if bareJid != jid {
t.Errorf("incorrect bare jid: %s", bareJid)
}
}