From 42b540be98673ed56bca05c273a2b10c4a67ebbd Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Wed, 13 Nov 2024 17:15:43 -0500 Subject: [PATCH] Additional coverage for each iteration with undefined item and specified key --- .../test/keywords/each-test.ts | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 packages/@glimmer-workspace/integration-tests/test/keywords/each-test.ts diff --git a/packages/@glimmer-workspace/integration-tests/test/keywords/each-test.ts b/packages/@glimmer-workspace/integration-tests/test/keywords/each-test.ts new file mode 100644 index 0000000000..88f48f7582 --- /dev/null +++ b/packages/@glimmer-workspace/integration-tests/test/keywords/each-test.ts @@ -0,0 +1,29 @@ +import { defineComponent, jitSuite, RenderTest, test, tracked } from '../..'; + +class Each extends RenderTest { + static suiteName = '{{#each}} keyword'; + + @test + 'each with undefined item https://github.com/emberjs/ember.js/issues/20786'() { + class State { + @tracked data = [undefined]; + } + + let state = new State(); + + const Bar = defineComponent( + { state }, + `{{#each state.data key='anything' as |datum|}} + {{datum}} + {{/each}}` + .replaceAll(/^\s|\s+$|\s+(?=\s)/gu, '') + .replaceAll(/\n/gu, '') + ); + + this.renderComponent(Bar); + + this.assertHTML(' '); + } +} + +jitSuite(Each);