@@ -27,38 +27,40 @@ describe('Environment: ETI', () => {
27
27
} ) ;
28
28
} ) ;
29
29
30
- test ( 'handles multi-byte characters' , ( ) => {
31
- let source = [
32
- `const a = <template>one 💩</template>;` ,
33
- `const b = <template>two</template>;` ,
34
- `const c = "‘foo’";` ,
35
- `const d = <template>four</template>;` ,
36
- ] . join ( '\n' ) ;
37
-
38
- let result = preprocess ( source , 'index.gts' ) ;
30
+ describe ( 'character testing' , ( ) => {
31
+ test ( '‘, 💩' , ( ) => {
32
+ let source = [
33
+ `const a = <template>one 💩</template>;` ,
34
+ `const b = <template>two</template>;` ,
35
+ `const c = "‘foo’";` ,
36
+ `const d = <template>four</template>;` ,
37
+ ] . join ( '\n' ) ;
38
+
39
+ let result = preprocess ( source , 'index.gts' ) ;
40
+
41
+ expect ( result . contents ) . toMatchInlineSnapshot ( `
42
+ "const a = [___T\`one 💩\`];
43
+ const b = [___T\`two\`];
44
+ const c = "‘foo’";
45
+ const d = [___T\`four\`];"
46
+ ` ) ;
47
+ } ) ;
39
48
40
- expect ( result . contents ) . toMatchInlineSnapshot ( `
41
- "const a = [___T\`one 💩\`];
42
- const b = [___T\`two\`];
43
- const c = "‘foo’";
44
- const d = [___T\`four\`];"
45
- ` ) ;
46
- } ) ;
49
+ test ( '$' , ( ) => {
50
+ let source = '<template>${{dollarAmount}}</template>;' ;
47
51
48
- test ( 'handles the $ character' , ( ) => {
49
- let source = '<template>${{dollarAmount}}</template>;' ;
52
+ let result = preprocess ( source , 'index.gts' ) ;
50
53
51
- let result = preprocess ( source , 'index.gts' ) ;
54
+ expect ( result . contents ) . toMatchInlineSnapshot ( '"[___T`\\${{dollarAmount}}`];"' ) ;
55
+ } ) ;
52
56
53
- expect ( result . contents ) . toMatchInlineSnapshot ( '"[___T`\\${{dollarAmount}}`];"' ) ;
54
- } ) ;
57
+ test ( '`' , ( ) => {
58
+ let source = '<template>`code`</template>;' ;
55
59
56
- test ( 'handles the ` character' , ( ) => {
57
- let source = '<template>`code`</template>;' ;
60
+ let result = preprocess ( source , 'index.gts' ) ;
58
61
59
- let result = preprocess ( source , 'index.gts' ) ;
60
-
61
- expect ( result . contents ) . toMatchInlineSnapshot ( '"[___T`\\`code\\``];"' ) ;
62
+ expect ( result . contents ) . toMatchInlineSnapshot ( '"[___T`\\`code\\``];"' ) ;
63
+ } ) ;
62
64
} ) ;
63
65
64
66
test ( 'multiple templates' , ( ) => {
@@ -199,6 +201,66 @@ describe('Environment: ETI', () => {
199
201
) ;
200
202
} ) ;
201
203
204
+ describe ( 'character testing' , ( ) => {
205
+ test ( '‘, 💩' , ( ) => {
206
+ let source = [
207
+ `const a = <template>one 💩</template>;` ,
208
+ `const b = <template>two</template>;` ,
209
+ `const c = "‘foo’";` ,
210
+ `const d = <template>four</template>;` ,
211
+ ] . join ( '\n' ) ;
212
+
213
+ let { sourceFile } = applyTransform ( source ) ;
214
+
215
+ expect ( sourceFile . text ) . toMatchInlineSnapshot ( `
216
+ "const a = [___T\`one 💩\`];
217
+ const b = [___T\`two\`];
218
+ const c = "‘foo’";
219
+ const d = [___T\`four\`];"
220
+ ` ) ;
221
+ } ) ;
222
+
223
+ test ( '$' , ( ) => {
224
+ let source = 'const foo = 2;\n\n<template>${{foo}}</template>\n' ;
225
+ let { sourceFile } = applyTransform ( source ) ;
226
+
227
+ expect ( sourceFile . text ) . toMatchInlineSnapshot ( `
228
+ "const foo = 2;
229
+
230
+ [___T\`\\\${{foo}}\`]
231
+ "
232
+ ` ) ;
233
+ } ) ;
234
+
235
+ test ( '`' , ( ) => {
236
+ let source = '<template>`code`</template>;' ;
237
+ let { meta, sourceFile } = applyTransform ( source ) ;
238
+ let templateNode = ( sourceFile . statements [ 1 ] as ts . ExpressionStatement ) . expression ;
239
+
240
+ let start = source . indexOf ( '<template>' ) ;
241
+ let contentStart = start + '<template>' . length ;
242
+ let contentEnd = source . indexOf ( '</template>' ) ;
243
+ let end = contentEnd + '</template>' . length ;
244
+
245
+ expect ( meta ) . toEqual (
246
+ new Map ( [
247
+ [
248
+ templateNode ,
249
+ {
250
+ prepend : 'export default ' ,
251
+ templateLocation : {
252
+ start,
253
+ contentStart,
254
+ contentEnd,
255
+ end,
256
+ } ,
257
+ } ,
258
+ ] ,
259
+ ] ) ,
260
+ ) ;
261
+ } ) ;
262
+ } ) ;
263
+
202
264
test ( 'single template with satisfies' , ( ) => {
203
265
let source = stripIndent `
204
266
import type { TOC } from '@ember/component/template-only';
0 commit comments