Skip to content

Commit e9bad5d

Browse files
committed
Adds updates + move algorithm works.
1 parent 17fdc86 commit e9bad5d

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

Tests/AlgorithmTests.swift

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,37 @@ extension AlgorithmTests {
140140

141141
XCTAssertEqual(initial.apply(differences), final)
142142
}
143+
144+
func testItemUpdatedAndMoved() {
145+
let initial: [s] = [
146+
s(1, [
147+
i(0, ""),
148+
i(1, ""),
149+
i(2, ""),
150+
])
151+
]
152+
153+
let final: [s] = [
154+
s(1, [
155+
i(1, "u"),
156+
i(0, ""),
157+
i(2, ""),
158+
])
159+
]
160+
161+
let differences = try! differencesForSectionedView(initialSections: initial, finalSections: final)
162+
163+
XCTAssertTrue(differences.count == 2)
164+
165+
// updates ok
166+
XCTAssertTrue(differences[0].onlyContains(updatedItems: 1))
167+
XCTAssertTrue(differences[0].updatedItems[0] == ItemPath(sectionIndex: 0, itemIndex: 1))
168+
169+
// moves ok
170+
XCTAssertTrue(differences[1].onlyContains(movedItems: 1))
171+
172+
XCTAssertEqual(initial.apply(differences), final)
173+
}
143174
}
144175

145176
// multiple sections simple

0 commit comments

Comments
 (0)