File tree 1 file changed +45
-0
lines changed
tests/test-app/tests/utils/function
1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -234,4 +234,49 @@ module('Utils | trackedFunction | rendering', function (hooks) {
234
234
await settled ();
235
235
assert .dom (' out' ).containsText (' 12.206' );
236
236
});
237
+
238
+ test (' failing case' , async function (assert ) {
239
+ class TestCase {
240
+ items = trackedFunction (this , async () => {
241
+ const items = await Promise .resolve ([3 , 4 , 5 ]);
242
+
243
+ return items ;
244
+ })
245
+
246
+ get firstItem() {
247
+ return this .items .value ?.[0 ];
248
+ }
249
+
250
+ stringArray = trackedFunction (this , async () => {
251
+ if (! this .firstItem ) return [];
252
+
253
+ const stringArray = await Promise .resolve (Array .from ({ length: this .firstItem }, () => ' item' ));
254
+
255
+ return stringArray ;
256
+ })
257
+
258
+ get endResult() {
259
+ return this .stringArray .value ?.join (' ,' ) ?? [].join (' ' )
260
+ }
261
+ }
262
+
263
+ class TestComponent extends Component {
264
+ @tracked testCase? : TestCase ;
265
+
266
+ setTestCase = () => this .testCase = new TestCase ();
267
+
268
+ <template >
269
+ <out >{{this .testCase.endResult }} </out >
270
+ <button type =" button" {{on " click" this . setTestCase}} ></button >
271
+ </template >
272
+ }
273
+
274
+ await render (<template ><TestComponent /></template >);
275
+
276
+ assert .dom (' out' ).doesNotIncludeText (' item' )
277
+
278
+ await click (' button' )
279
+
280
+ assert .dom (' out' ).hasText (' item,item,item' )
281
+ })
237
282
});
You can’t perform that action at this time.
0 commit comments