@@ -4,16 +4,16 @@ import org.scalatest.{FlatSpec, Matchers}
4
4
5
5
class XmlCompareSpec extends FlatSpec with Matchers {
6
6
7
- " comparing empty " should " match same element name " in {
7
+ " compare with defaults " should " match same empty element " in {
8
8
XmlCompare .compare(<test />, <test />) shouldBe XmlEqual
9
9
}
10
10
11
- it should " blah " in {
11
+ it should " match empty elements ignoring collapsed " in {
12
12
XmlCompare .compare(<test />, <test ></test >) shouldBe XmlEqual
13
13
}
14
14
15
- it should " not-match" in {
16
- XmlCompare .compare(<test />, <foo />) shouldBe XmlDiffers (" different label" )
15
+ it should " not-match different label " in {
16
+ XmlCompare .compare(<test />, <foo />) shouldBe XmlDiffers (" different label" , " test " , " foo " )
17
17
}
18
18
19
19
it should " match same namespaces" in {
@@ -26,15 +26,44 @@ class XmlCompareSpec extends FlatSpec with Matchers {
26
26
<e : test xmlns : e =" http://example.com" />) shouldBe XmlEqual
27
27
}
28
28
29
- it should " not-match different namespace prefix (with IgnorePrefix disabled) " in {
29
+ it should " not-match different namespace url " in {
30
30
XmlCompare .compare(
31
31
<t : test xmlns : t =" http://example.com" />,
32
- <e : test xmlns : e =" http://example.com" />, Set .empty) shouldBe XmlDiffers (" different prefix" )
32
+ <t : test xmlns : t =" http://foo.com" />) shouldBe
33
+ XmlDiffers (
34
+ " different namespace" ,
35
+ " http://example.com" ,
36
+ " http://foo.com" )
33
37
}
34
38
35
- it should " not-match different namespace url" in {
39
+ it should " match with same single child" in {
40
+ XmlCompare .compare(<test ><test2 /></test >, <test ><test2 /></test >) shouldBe XmlEqual
41
+ }
42
+
43
+ it should " not-match with different single child" in {
44
+ XmlCompare .compare(<test ><test2 /></test >, <test ><foo /></test >) shouldBe XmlDiffers (" different label" , " test2" , " foo" )
45
+ }
46
+
47
+ it should " match with same text contents" in {
48
+ XmlCompare .compare(<test >contents</test >, <test >contents</test >) shouldBe XmlEqual
49
+ }
50
+
51
+ it should " not-match different text contents" in {
52
+ XmlCompare .compare(<test >contents</test >, <test />) shouldBe XmlDiffers (" different text" , " contents" , " " )
53
+ }
54
+
55
+ it should " match with text content differing only by whitespace" in {
56
+ XmlCompare .compare(<test >contents </test >, <test >contents</test >) shouldBe XmlEqual
57
+ }
58
+
59
+ it should " match with child & text content in different order" in {
60
+ XmlCompare .compare(<test ><test2 />contents</test >, <test >contents<test2 /></test >) shouldBe XmlEqual
61
+ }
62
+
63
+
64
+ " compare without IgnorePrefix" should " not-match different namespace prefix" in {
36
65
XmlCompare .compare(
37
66
<t : test xmlns : t =" http://example.com" />,
38
- <t : test xmlns : t =" http://foo .com" />) shouldBe XmlDiffers (" different namespace " )
67
+ <e : test xmlns : e =" http://example .com" />, Set .empty ) shouldBe XmlDiffers (" different prefix " , " t " , " e " )
39
68
}
40
69
}
0 commit comments