|
1 | | -import { tracked } from '@ember/-internals/metal'; |
2 | 1 | import { template } from '@ember/template-compiler/runtime'; |
3 | | -import { RenderingTestCase, defineSimpleModifier, moduleFor, runTask } from 'internal-test-helpers'; |
| 2 | +import { RenderingTestCase, defineSimpleModifier, moduleFor } from 'internal-test-helpers'; |
4 | 3 | import GlimmerishComponent from '../../utils/glimmerish-component'; |
5 | 4 | import { on } from '@ember/modifier/on'; |
6 | 5 | import { fn } from '@ember/helper'; |
7 | 6 |
|
8 | 7 | moduleFor( |
9 | 8 | 'Strict Mode - Runtime Template Compiler (implicit)', |
10 | 9 | class extends RenderingTestCase { |
11 | | - async '@test can have in-scope tracked data'(assert: Assert) { |
| 10 | + async '@test can immediately render a runtime-compiled template'() { |
12 | 11 | class State { |
13 | | - @tracked str = `hello there`; |
14 | | - |
15 | 12 | get component() { |
16 | | - assert.step('get component'); |
17 | | - |
18 | | - let getStr = () => { |
19 | | - assert.step('getStr()'); |
20 | | - return this.str; |
21 | | - }; |
22 | | - |
23 | | - hide(getStr); |
24 | | - |
25 | | - return template(`{{ (getStr) }}`, { |
26 | | - eval() { |
27 | | - return eval(arguments[0]); |
28 | | - }, |
29 | | - }); |
| 13 | + return template(`hello there`); |
30 | 14 | } |
31 | 15 | } |
32 | 16 |
|
| 17 | + // eslint-disable-next-line @typescript-eslint/no-unused-vars |
33 | 18 | let state = new State(); |
34 | 19 |
|
35 | 20 | await this.renderComponentModule(() => { |
36 | 21 | return template('<state.component />', { |
37 | 22 | eval() { |
38 | | - assert.step('eval'); |
39 | 23 | return eval(arguments[0]); |
40 | 24 | }, |
41 | 25 | }); |
42 | 26 | }); |
43 | 27 |
|
44 | 28 | this.assertHTML('hello there'); |
45 | 29 | this.assertStableRerender(); |
46 | | - assert.verifySteps([ |
47 | | - // for every value in the component, for eevry node traversed in the compiler |
48 | | - 'eval', // precompileJSON -> ... ElementNode -> ... -> lexicalScope -> isScope('state', ...) |
49 | | - 'eval', // "..." |
50 | | - 'eval', // "..." |
51 | | - 'eval', // creating the templateFactory |
52 | | - 'get component', |
53 | | - 'getStr()', |
54 | | - ]); |
55 | | - |
56 | | - runTask(() => (state.str += '!')); |
57 | | - |
58 | | - this.assertHTML('hello there!'); |
59 | | - this.assertStableRerender(); |
60 | | - assert.verifySteps(['getStr()']); |
61 | 30 | } |
62 | 31 |
|
63 | 32 | async '@test Can use a component in scope'() { |
|
0 commit comments