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 @@ -226,4 +226,49 @@ module('Utils | trackedFunction | rendering', function (hooks) {
226
226
await settled ();
227
227
assert .dom (' out' ).containsText (' 12.206' );
228
228
});
229
+
230
+ test (' failing case' , async function (assert ) {
231
+ class TestCase {
232
+ items = trackedFunction (this , async () => {
233
+ const items = await Promise .resolve ([3 , 4 , 5 ]);
234
+
235
+ return items ;
236
+ })
237
+
238
+ get firstItem() {
239
+ return this .items .value ?.[0 ];
240
+ }
241
+
242
+ stringArray = trackedFunction (this , async () => {
243
+ if (! this .firstItem ) return [];
244
+
245
+ const stringArray = await Promise .resolve (Array .from ({ length: this .firstItem }, () => ' item' ));
246
+
247
+ return stringArray ;
248
+ })
249
+
250
+ get endResult() {
251
+ return this .stringArray .value ?.join (' ,' ) ?? [].join (' ' )
252
+ }
253
+ }
254
+
255
+ class TestComponent extends Component {
256
+ @tracked testCase? : TestCase ;
257
+
258
+ setTestCase = () => this .testCase = new TestCase ();
259
+
260
+ <template >
261
+ <out >{{this .testCase.endResult }} </out >
262
+ <button type =" button" {{on " click" this . setTestCase}} ></button >
263
+ </template >
264
+ }
265
+
266
+ await render (<template ><TestComponent /></template >);
267
+
268
+ assert .dom (' out' ).doesNotIncludeText (' item' )
269
+
270
+ await click (' button' )
271
+
272
+ assert .dom (' out' ).hasText (' item,item,item' )
273
+ })
229
274
});
You can’t perform that action at this time.
0 commit comments