Skip to content

Commit

Permalink
feat: add initial parent test
Browse files Browse the repository at this point in the history
  • Loading branch information
drmohundro committed Nov 1, 2023
1 parent a3e0af6 commit 0b84d87
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Tests/SWXMLHashTests/XMLParsingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ class XMLParsingTests: XCTestCase {
XCTAssertEqual(xml!["root"]["catalog"]["book"][1]["author"].element?.text, "Ralls, Kim")
}

func testShouldBeAbleToGetParent() {
XCTAssertNotNil(xml!["root"]["catalog"]["book"][1]["author"].element?.parent)
XCTAssertEqual(xml!["root"]["catalog"]["book"][1]["author"].element?.parent?.name, "book")
XCTAssertEqual(xml!["root"]["catalog"]["book"][1]["author"].element?.parent?.attribute(by: "id")?.text, "bk102")
}

func testShouldBeAbleToParseElementGroupsByIndex() {
XCTAssertEqual(try xml!["root"]["catalog"]["book"].byIndex(1)["author"].element?.text, "Ralls, Kim")
}
Expand Down

0 comments on commit 0b84d87

Please sign in to comment.