@@ -4,16 +4,16 @@ import org.scalatest.{FlatSpec, Matchers}
44
55class XmlCompareSpec extends FlatSpec with Matchers {
66
7- " comparing empty " should " match same element name " in {
7+ " compare with defaults " should " match same empty element " in {
88 XmlCompare .compare(<test />, <test />) shouldBe XmlEqual
99 }
1010
11- it should " blah " in {
11+ it should " match empty elements ignoring collapsed " in {
1212 XmlCompare .compare(<test />, <test ></test >) shouldBe XmlEqual
1313 }
1414
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 " )
1717 }
1818
1919 it should " match same namespaces" in {
@@ -26,15 +26,44 @@ class XmlCompareSpec extends FlatSpec with Matchers {
2626 <e : test xmlns : e =" http://example.com" />) shouldBe XmlEqual
2727 }
2828
29- it should " not-match different namespace prefix (with IgnorePrefix disabled) " in {
29+ it should " not-match different namespace url " in {
3030 XmlCompare .compare(
3131 <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" )
3337 }
3438
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 {
3665 XmlCompare .compare(
3766 <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 " )
3968 }
4069}
0 commit comments