@@ -4,103 +4,106 @@ import { GlintEnvironment } from '@glint/config';
4
4
5
5
describe ( 'Debug utilities' , ( ) => {
6
6
test ( 'TransformedModule#toDebugString' , ( ) => {
7
- let code = stripIndent `
8
- import Component, { hbs } from '@glimmerx/component';
7
+ let script = {
8
+ filename : 'test.ts' ,
9
+ contents : stripIndent `
10
+ import Component, { hbs } from '@glimmerx/component';
9
11
10
- export default class MyComponent extends Component {
11
- private bar = 'hi';
12
+ export default class MyComponent extends Component {
13
+ private bar = 'hi';
12
14
13
- static template = hbs\`
14
- <HelperComponent @foo={{this.bar}} />
15
- \`;
16
- }
15
+ static template = hbs\`
16
+ <HelperComponent @foo={{this.bar}} />
17
+ \`;
18
+ }
17
19
18
- class HelperComponent extends Component<{ foo: string }> {
19
- static template = hbs\`
20
- Hello, {{@foo}}
21
- \`;
22
- }
23
- ` ;
20
+ class HelperComponent extends Component<{ foo: string }> {
21
+ static template = hbs\`
22
+ Hello, {{@foo}}
23
+ \`;
24
+ }
25
+ ` ,
26
+ } ;
24
27
25
- let transformedModule = rewriteModule ( 'test.ts' , code , GlintEnvironment . load ( 'glimmerx' ) ) ;
28
+ let transformedModule = rewriteModule ( { script } , GlintEnvironment . load ( 'glimmerx' ) ) ;
26
29
27
30
expect ( transformedModule ?. toDebugString ( ) ) . toMatchInlineSnapshot ( `
28
- "TransformedModule test.ts
31
+ "TransformedModule
29
32
30
33
| Mapping: Template
31
34
| hbs(0:50): hbs\`\\\\n <HelperComponent @foo={{this.bar}} />\\\\n \`
32
35
| ts(0:277): (() => {\\\\n hbs;\\\\n let χ!: typeof import(\\"@glint/environment-glimmerx/types\\");\\\\n return χ.template(function(𝚪: import(\\"@glint/environment-glimmerx/types\\").ResolveContext<MyComponent>) {\\\\n χ.invokeBlock(χ.resolve(HelperComponent)({ foo: 𝚪.this.bar }), {});\\\\n 𝚪;\\\\n });\\\\n})()
33
- |
36
+ |
34
37
| | Mapping: Identifier
35
- | | hbs(0:0):
38
+ | | hbs(0:0):
36
39
| | ts(170:181): MyComponent
37
- | |
40
+ | |
38
41
| | Mapping: ElementNode
39
42
| | hbs(9:46): <HelperComponent @foo={{this.bar}} />
40
43
| | ts(186:259): χ.invokeBlock(χ.resolve(HelperComponent)({ foo: 𝚪.this.bar }), {});
41
- | |
44
+ | |
42
45
| | | Mapping: ElementNode
43
46
| | | hbs(9:46): <HelperComponent @foo={{this.bar}} />
44
47
| | | ts(186:259): χ.invokeBlock(χ.resolve(HelperComponent)({ foo: 𝚪.this.bar }), {});
45
- | | |
48
+ | | |
46
49
| | | | Mapping: Identifier
47
50
| | | | hbs(10:25): HelperComponent
48
51
| | | | ts(214:229): HelperComponent
49
- | | | |
52
+ | | | |
50
53
| | | | Mapping: AttrNode
51
54
| | | | hbs(26:43): @foo={{this.bar}}
52
55
| | | | ts(233:249): foo: 𝚪.this.bar
53
- | | | |
56
+ | | | |
54
57
| | | | | Mapping: Identifier
55
58
| | | | | hbs(27:30): foo
56
59
| | | | | ts(233:236): foo
57
- | | | | |
60
+ | | | | |
58
61
| | | | | Mapping: MustacheStatement
59
62
| | | | | hbs(31:43): {{this.bar}}
60
63
| | | | | ts(238:249): 𝚪.this.bar
61
- | | | | |
64
+ | | | | |
62
65
| | | | | | Mapping: PathExpression
63
66
| | | | | | hbs(33:41): this.bar
64
67
| | | | | | ts(238:249): 𝚪.this.bar
65
- | | | | | |
68
+ | | | | | |
66
69
| | | | | | | Mapping: Identifier
67
70
| | | | | | | hbs(33:37): this
68
71
| | | | | | | ts(241:245): this
69
- | | | | | | |
72
+ | | | | | | |
70
73
| | | | | | | Mapping: Identifier
71
74
| | | | | | | hbs(38:41): bar
72
75
| | | | | | | ts(246:249): bar
73
- | | | | | | |
74
- | | | | | |
75
- | | | | |
76
- | | | |
77
- | | |
78
- | |
79
- |
76
+ | | | | | | |
77
+ | | | | | |
78
+ | | | | |
79
+ | | | |
80
+ | | |
81
+ | |
82
+ |
80
83
81
84
| Mapping: Template
82
85
| hbs(0:28): hbs\`\\\\n Hello, {{@foo}}\\\\n \`
83
86
| ts(0:262): (() => {\\\\n hbs;\\\\n let χ!: typeof import(\\"@glint/environment-glimmerx/types\\");\\\\n return χ.template(function(𝚪: import(\\"@glint/environment-glimmerx/types\\").ResolveContext<HelperComponent>) {\\\\n χ.invokeEmit(χ.resolveOrReturn(𝚪.args.foo)({}));\\\\n 𝚪;\\\\n });\\\\n})()
84
- |
87
+ |
85
88
| | Mapping: Identifier
86
- | | hbs(0:0):
89
+ | | hbs(0:0):
87
90
| | ts(170:185): HelperComponent
88
- | |
91
+ | |
89
92
| | Mapping: MustacheStatement
90
93
| | hbs(16:24): {{@foo}}
91
94
| | ts(190:242): χ.invokeEmit(χ.resolveOrReturn(𝚪.args.foo)({}))
92
- | |
95
+ | |
93
96
| | | Mapping: PathExpression
94
97
| | | hbs(18:22): @foo
95
98
| | | ts(225:236): 𝚪.args.foo
96
- | | |
99
+ | | |
97
100
| | | | Mapping: Identifier
98
101
| | | | hbs(19:22): foo
99
102
| | | | ts(233:236): foo
100
- | | | |
101
- | | |
102
- | |
103
- | "
103
+ | | | |
104
+ | | |
105
+ | |
106
+ |"
104
107
` ) ;
105
108
} ) ;
106
109
} ) ;
0 commit comments