File tree 1 file changed +19
-0
lines changed
Tests/ComposableArchitectureTests
1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,25 @@ final class ObservableTests: BaseTCATestCase {
43
43
XCTAssertEqual ( state. children [ 0 ] . count, 43 )
44
44
}
45
45
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
+
46
65
func testReplace( ) async {
47
66
XCTTODO ( " Ideally this would pass but we cannot detect this kind of mutation currently. " )
48
67
You can’t perform that action at this time.
0 commit comments