Skip to content

Commit

Permalink
Repro for #1629
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Oct 15, 2024
1 parent d436dc4 commit e8f4a13
Showing 1 changed file with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { assign } from '@glimmer/util';
import {
BaseEnv,
GlimmerishComponent,
JitRenderDelegate,
RenderTest,
suite,
test,
tracked,
} from '..';

class LazyInitializationTest extends RenderTest {
static suiteName = 'Application test: lazy initialization';

@test 'Should be able to lazily initialize a tracked property'() {
class X extends GlimmerishComponent {
@tracked _counts: number | undefined = undefined;

get counts() {
if (this._counts === undefined) {
this._counts = 0;
}

return this._counts;
}

increment = () => this._counts!++;
}
this.registerComponent(
'Glimmer',
'HelloWorld',
`
{{this._counts}}
{{this.counts}}
`,
X
);

this.render(`<HelloWorld />`);

this.assertHTML(`0 0`);
}
}

suite(LazyInitializationTest, JitRenderDelegate, {
env: assign({}, BaseEnv, {
enableDebugTooling: false,
}),
});

0 comments on commit e8f4a13

Please sign in to comment.