forked from ortuman/jackal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmutable_element_test.go
35 lines (30 loc) · 952 Bytes
/
mutable_element_test.go
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
/*
* Copyright (c) 2018 Miguel Ángel Ortuño.
* See the LICENSE file for more information.
*/
package xmpp
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestElement_RemoveAttribute(t *testing.T) {
e := NewElementNamespace("n", "ns")
require.Equal(t, "ns", e.Attributes().Get("xmlns"))
e.RemoveAttribute("xmlns")
require.Equal(t, "", e.Attributes().Get("xmlns"))
}
func TestElement_RemoveElements(t *testing.T) {
e := NewElementName("n")
e.AppendElement(NewElementNamespace("a", "ns1"))
e.AppendElement(NewElementNamespace("a", "ns2"))
e.AppendElement(NewElementNamespace("a", "ns3"))
e.AppendElement(NewElementName("b"))
e.AppendElement(NewElementName("c"))
require.Equal(t, 5, e.Elements().Count())
e.RemoveElementsNamespace("a", "ns3")
require.Equal(t, 4, e.Elements().Count())
e.RemoveElements("a")
require.Equal(t, 2, e.Elements().Count())
e.ClearElements()
require.Equal(t, 0, e.Elements().Count())
}