Closed saschagordner closed 3 years ago
The changes look good. I think it would be good to add one or two unit tests for this function. For example something like this:
func testReplaceAllSection() {
let form = Form() +++ Section("section1") {
$0.hidden = true
}
+++ Section("section2")
+++ Section("section3")
form.replaceSubrangeInAllSections(Range<Int>(uncheckedBounds: (lower: 0, upper: 2)), with: [Section("section0") { $0.hidden = true }])
XCTAssertEqual(form.allSections.count, 2)
XCTAssertEqual(form.count, 1)
XCTAssertEqual(form[0].header?.title, "section3")
XCTAssertEqual(form.allSections[0].header?.title, "section0")
XCTAssertEqual(form.allSections[1].header?.title, "section3")
}
This PR adds a new method
Form.replaceSubrangeInAllSections(_:with:)
which replaces a subrange of all sections (including hidden ones) with a given set of sections. In addition, it replaces existing visible sections within the subrange by the visible sections in the new element collection.@mats-claassen Please let me know if you have any concerns.
Resolves #2003