From b488d80e39e41722c140b4fef470ffc828cae7d7 Mon Sep 17 00:00:00 2001 From: Brad Overton Date: Fri, 13 Sep 2024 18:00:31 +1000 Subject: [PATCH 1/8] test: add potential failing test for #110 --- .../tests/utils/function/rendering-test.gts | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/test-app/tests/utils/function/rendering-test.gts b/tests/test-app/tests/utils/function/rendering-test.gts index 960f0d3..b8cd6bd 100644 --- a/tests/test-app/tests/utils/function/rendering-test.gts +++ b/tests/test-app/tests/utils/function/rendering-test.gts @@ -234,4 +234,49 @@ module('Utils | trackedFunction | rendering', function (hooks) { await settled(); assert.dom('out').containsText('12.206'); }); + + test('failing case', async function (assert) { + class TestCase { + items = trackedFunction(this, async () => { + const items = await Promise.resolve([3, 4, 5]); + + return items; + }) + + get firstItem() { + return this.items.value?.[0]; + } + + stringArray = trackedFunction(this, async () => { + if (!this.firstItem) return []; + + const stringArray = await Promise.resolve(Array.from({ length: this.firstItem }, () => 'item')); + + return stringArray; + }) + + get endResult() { + return this.stringArray.value?.join(',') ?? [].join('') + } + } + + class TestComponent extends Component { + @tracked testCase?: TestCase; + + setTestCase = () => this.testCase = new TestCase(); + + + } + + await render(); + + assert.dom('out').doesNotIncludeText('item') + + await click('button') + + assert.dom('out').hasText('item,item,item') + }) }); From acffbf016fa4450896b91d1a7e3064cf18a3d3f7 Mon Sep 17 00:00:00 2001 From: Brad Overton Date: Fri, 13 Sep 2024 18:06:34 +1000 Subject: [PATCH 2/8] chore: apply prettier --- .../tests/utils/function/rendering-test.gts | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/tests/test-app/tests/utils/function/rendering-test.gts b/tests/test-app/tests/utils/function/rendering-test.gts index b8cd6bd..a745ae2 100644 --- a/tests/test-app/tests/utils/function/rendering-test.gts +++ b/tests/test-app/tests/utils/function/rendering-test.gts @@ -241,7 +241,7 @@ module('Utils | trackedFunction | rendering', function (hooks) { const items = await Promise.resolve([3, 4, 5]); return items; - }) + }); get firstItem() { return this.items.value?.[0]; @@ -250,20 +250,22 @@ module('Utils | trackedFunction | rendering', function (hooks) { stringArray = trackedFunction(this, async () => { if (!this.firstItem) return []; - const stringArray = await Promise.resolve(Array.from({ length: this.firstItem }, () => 'item')); + const stringArray = await Promise.resolve( + Array.from({ length: this.firstItem }, () => 'item') + ); return stringArray; - }) + }); get endResult() { - return this.stringArray.value?.join(',') ?? [].join('') + return this.stringArray.value?.join(',') ?? [].join(''); } } class TestComponent extends Component { @tracked testCase?: TestCase; - setTestCase = () => this.testCase = new TestCase(); + setTestCase = () => (this.testCase = new TestCase());