@@ -92,7 +92,7 @@ function Square(props: {squareId: SquareId}) {
92
92
if ( data == null ) {
93
93
data = use ( fetchData ( props . squareId ) ) ;
94
94
}
95
- return < View key = { data . color } nativeID = { ' square with data: ' + data . color } /> ;
95
+ return < View key = { data . color } nativeID = { ` square- with- data- ${ data . color } ` } /> ;
96
96
}
97
97
98
98
function GreenSquare ( ) {
@@ -104,7 +104,7 @@ function RedSquare() {
104
104
}
105
105
106
106
function Fallback ( ) {
107
- return < View nativeID = "suspense fallback" /> ;
107
+ return < View nativeID = "suspense- fallback" /> ;
108
108
}
109
109
110
110
describe ( 'Suspense' , ( ) => {
@@ -120,25 +120,24 @@ describe('Suspense', () => {
120
120
) ;
121
121
} ) ;
122
122
123
- let mountingLogs = root . takeMountingManagerLogs ( ) ;
124
-
125
- expect ( mountingLogs . length ) . toBe ( 1 ) ;
126
- expect ( mountingLogs [ 0 ] ) . toBe (
127
- 'create view type: `View` nativeId: `suspense fallback`' ,
128
- ) ;
123
+ expect ( root . takeMountingManagerLogs ( ) ) . toEqual ( [
124
+ 'Update {type: "RootView", nativeID: (root)}' ,
125
+ 'Create {type: "View", nativeID: "suspense-fallback"}' ,
126
+ 'Insert {type: "View", parentNativeID: (root), index: 0, nativeID: "suspense-fallback"}' ,
127
+ ] ) ;
129
128
130
129
expect ( resolveFunction ) . not . toBeNull ( ) ;
131
130
Fantom . runTask ( ( ) => {
132
131
resolveFunction ?. ( ) ;
133
132
resolveFunction = null ;
134
133
} ) ;
135
134
136
- mountingLogs = root . takeMountingManagerLogs ( ) ;
137
-
138
- expect ( mountingLogs . length ) . toBe ( 1 ) ;
139
- expect ( mountingLogs [ 0 ] ) . toBe (
140
- 'create view type: ` View` nativeId: `square with data: green` ' ,
141
- ) ;
135
+ expect ( root . takeMountingManagerLogs ( ) ) . toEqual ( [
136
+ 'Remove {type: "View", parentNativeID: (root), index: 0, nativeID: "suspense-fallback"}' ,
137
+ 'Delete {type: "View", nativeID: "suspense-fallback"}' ,
138
+ 'Create {type: "View", nativeID: "square-with-data-green"}' ,
139
+ 'Insert { type: " View", parentNativeID: (root), index: 0, nativeID: "square-with-data- green"} ' ,
140
+ ] ) ;
142
141
143
142
Fantom . runTask ( ( ) => {
144
143
root . render (
@@ -148,25 +147,25 @@ describe('Suspense', () => {
148
147
) ;
149
148
} ) ;
150
149
151
- mountingLogs = root . takeMountingManagerLogs ( ) ;
152
-
153
- expect ( mountingLogs . length ) . toBe ( 1 ) ;
154
- expect ( mountingLogs [ 0 ] ) . toBe (
155
- 'create view type: ` View` nativeId: `suspense fallback` ' ,
156
- ) ;
150
+ expect ( root . takeMountingManagerLogs ( ) ) . toEqual ( [
151
+ 'Remove {type: "View", parentNativeID: (root), index: 0, nativeID: "square-with-data-green"}' ,
152
+ 'Delete {type: "View", nativeID: "square-with-data-green"}' ,
153
+ 'Create {type: "View", nativeID: "suspense-fallback"}' ,
154
+ 'Insert { type: " View", parentNativeID: (root), index: 0, nativeID: "suspense- fallback"} ' ,
155
+ ] ) ;
157
156
158
157
expect ( resolveFunction ) . not . toBeNull ( ) ;
159
158
Fantom . runTask ( ( ) => {
160
159
resolveFunction ?. ( ) ;
161
160
resolveFunction = null ;
162
161
} ) ;
163
162
164
- mountingLogs = root . takeMountingManagerLogs ( ) ;
165
-
166
- expect ( mountingLogs . length ) . toBe ( 1 ) ;
167
- expect ( mountingLogs [ 0 ] ) . toBe (
168
- 'create view type: ` View` nativeId: `square with data: red` ' ,
169
- ) ;
163
+ expect ( root . takeMountingManagerLogs ( ) ) . toEqual ( [
164
+ 'Remove {type: "View", parentNativeID: (root), index: 0, nativeID: "suspense-fallback"}' ,
165
+ 'Delete {type: "View", nativeID: "suspense-fallback"}' ,
166
+ 'Create {type: "View", nativeID: "square-with-data-red"}' ,
167
+ 'Insert { type: " View", parentNativeID: (root), index: 0, nativeID: "square-with-data- red"} ' ,
168
+ ] ) ;
170
169
171
170
Fantom . runTask ( ( ) => {
172
171
root . render (
@@ -176,12 +175,12 @@ describe('Suspense', () => {
176
175
) ;
177
176
} ) ;
178
177
179
- mountingLogs = root . takeMountingManagerLogs ( ) ;
180
-
181
- expect ( mountingLogs . length ) . toBe ( 1 ) ;
182
- expect ( mountingLogs [ 0 ] ) . toBe (
183
- 'create view type: ` View` nativeId: `square with data: green` ' ,
184
- ) ;
178
+ expect ( root . takeMountingManagerLogs ( ) ) . toEqual ( [
179
+ 'Remove {type: "View", parentNativeID: (root), index: 0, nativeID: "square-with-data-red"}' ,
180
+ 'Delete {type: "View", nativeID: "square-with-data-red"}' ,
181
+ 'Create {type: "View", nativeID: "square-with-data-green"}' ,
182
+ 'Insert { type: " View", parentNativeID: (root), index: 0, nativeID: "square-with-data- green"} ' ,
183
+ ] ) ;
185
184
186
185
expect ( resolveFunction ) . toBeNull ( ) ;
187
186
} ) ;
@@ -206,12 +205,11 @@ describe('Suspense', () => {
206
205
root . render ( < App color = "green" /> ) ;
207
206
} ) ;
208
207
209
- let mountingLogs = root . takeMountingManagerLogs ( ) ;
210
-
211
- expect ( mountingLogs . length ) . toBe ( 1 ) ;
212
- expect ( mountingLogs [ 0 ] ) . toBe (
213
- 'create view type: `View` nativeId: `square with data: green`' ,
214
- ) ;
208
+ expect ( root . takeMountingManagerLogs ( ) ) . toEqual ( [
209
+ 'Update {type: "RootView", nativeID: (root)}' ,
210
+ 'Create {type: "View", nativeID: "square-with-data-green"}' ,
211
+ 'Insert {type: "View", parentNativeID: (root), index: 0, nativeID: "square-with-data-green"}' ,
212
+ ] ) ;
215
213
216
214
expect ( resolveFunction ) . toBeNull ( ) ;
217
215
Fantom . runTask ( ( ) => {
@@ -220,22 +218,20 @@ describe('Suspense', () => {
220
218
} ) ;
221
219
} ) ;
222
220
223
- mountingLogs = root . takeMountingManagerLogs ( ) ;
224
-
225
221
// Green square is still mounted. Fallback is not shown to the user.
226
- expect ( mountingLogs . length ) . toBe ( 0 ) ;
222
+ expect ( root . takeMountingManagerLogs ( ) ) . toEqual ( [ ] ) ;
227
223
228
224
expect ( resolveFunction ) . not . toBeNull ( ) ;
229
225
Fantom . runTask ( ( ) => {
230
226
resolveFunction ?. ( ) ;
231
227
resolveFunction = null ;
232
228
} ) ;
233
229
234
- mountingLogs = root . takeMountingManagerLogs ( ) ;
235
-
236
- expect ( mountingLogs . length ) . toBe ( 1 ) ;
237
- expect ( mountingLogs [ 0 ] ) . toBe (
238
- 'create view type: ` View` nativeId: `square with data: red` ' ,
239
- ) ;
230
+ expect ( root . takeMountingManagerLogs ( ) ) . toEqual ( [
231
+ 'Remove {type: "View", parentNativeID: (root), index: 0, nativeID: "square-with-data-green"}' ,
232
+ 'Delete {type: "View", nativeID: "square-with-data-green"}' ,
233
+ 'Create {type: "View", nativeID: "square-with-data-red"}' ,
234
+ 'Insert { type: " View", parentNativeID: (root), index: 0, nativeID: "square-with-data- red"} ' ,
235
+ ] ) ;
240
236
} ) ;
241
237
} ) ;
0 commit comments