Skip to content

Commit 87608bc

Browse files
committed
Add missing test
1 parent 64cf3e8 commit 87608bc

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Tests/ComposableArchitectureTests/ObservableTests.swift

+19
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,25 @@ final class ObservableTests: BaseTCATestCase {
4343
XCTAssertEqual(state.children[0].count, 43)
4444
}
4545

46+
func testCopyMutation_WithPerturbation() async {
47+
var state = ParentState(children: [ChildState(count: 42)])
48+
let countDidChange = self.expectation(description: "count.didChange")
49+
var copy = state.children[0]
50+
copy.count += 1
51+
52+
withPerceptionTracking {
53+
_ = state.children[0].count
54+
} onChange: {
55+
countDidChange.fulfill()
56+
}
57+
58+
state.children[0] = copy
59+
state.children[0]._$willModify()
60+
61+
await self.fulfillment(of: [countDidChange], timeout: 0.1)
62+
XCTAssertEqual(state.children[0].count, 43)
63+
}
64+
4665
func testReplace() async {
4766
XCTTODO("Ideally this would pass but we cannot detect this kind of mutation currently.")
4867

0 commit comments

Comments
 (0)