@@ -18,6 +18,7 @@ import {
18
18
PropertyRead ,
19
19
TemplateBinding ,
20
20
VariableBinding ,
21
+ TemplateLiteral ,
21
22
} from '@angular/compiler/src/expression_parser/ast' ;
22
23
import { Lexer } from '@angular/compiler/src/expression_parser/lexer' ;
23
24
import { Parser , SplitInterpolation } from '@angular/compiler/src/expression_parser/parser' ;
@@ -528,18 +529,34 @@ describe('parser', () => {
528
529
expect ( unparseWithSpan ( ast ) ) . toContain ( [ 'a.b = c' , '[nameSpan] b' ] ) ;
529
530
} ) ;
530
531
531
- it ( 'should record template literal space' , ( ) => {
532
+ it ( 'should record spans for untagged template literals with no interpolations' , ( ) => {
533
+ const ast = parseAction ( '`hello world`' ) ;
534
+ const unparsed = unparseWithSpan ( ast ) ;
535
+ expect ( unparsed ) . toEqual ( [
536
+ [ '`hello world`' , '`hello world`' ] ,
537
+ [ 'hello world' , '`hello world`' ] ,
538
+ ] ) ;
539
+ } ) ;
540
+
541
+ it ( 'should record spans for untagged template literals with interpolations' , ( ) => {
532
542
const ast = parseAction ( '`before ${one} - ${two} - ${three} after`' ) ;
533
543
const unparsed = unparseWithSpan ( ast ) ;
534
- expect ( unparsed ) . toContain ( [ 'before ' , '' ] ) ;
535
- expect ( unparsed ) . toContain ( [ 'one' , 'one' ] ) ;
536
- expect ( unparsed ) . toContain ( [ 'one' , '[nameSpan] one' ] ) ;
537
- expect ( unparsed ) . toContain ( [ ' - ' , '' ] ) ;
538
- expect ( unparsed ) . toContain ( [ 'two' , 'two' ] ) ;
539
- expect ( unparsed ) . toContain ( [ 'two' , '[nameSpan] two' ] ) ;
540
- expect ( unparsed ) . toContain ( [ 'three' , 'three' ] ) ;
541
- expect ( unparsed ) . toContain ( [ 'three' , '[nameSpan] three' ] ) ;
542
- expect ( unparsed ) . toContain ( [ ' after' , '' ] ) ;
544
+ expect ( unparsed ) . toEqual ( [
545
+ [ '`before ${one} - ${two} - ${three} after`' , '`before ${one} - ${two} - ${three} after`' ] ,
546
+ [ 'before ' , '`before ' ] ,
547
+ [ 'one' , 'one' ] ,
548
+ [ 'one' , '[nameSpan] one' ] ,
549
+ [ '' , '' ] , // Implicit receiver
550
+ [ ' - ' , ' - ' ] ,
551
+ [ 'two' , 'two' ] ,
552
+ [ 'two' , '[nameSpan] two' ] ,
553
+ [ '' , '' ] , // Implicit receiver
554
+ [ ' - ' , ' - ' ] ,
555
+ [ 'three' , 'three' ] ,
556
+ [ 'three' , '[nameSpan] three' ] ,
557
+ [ '' , '' ] , // Implicit receiver
558
+ [ ' after' , ' after`' ] ,
559
+ ] ) ;
543
560
} ) ;
544
561
545
562
it ( 'should record spans for tagged template literal with no interpolations' , ( ) => {
@@ -549,9 +566,9 @@ describe('parser', () => {
549
566
[ 'tag`text`' , 'tag`text`' ] ,
550
567
[ 'tag' , 'tag' ] ,
551
568
[ 'tag' , '[nameSpan] tag' ] ,
552
- [ '' , '' ] ,
553
- [ '`text`' , '' ] ,
554
- [ 'text' , '' ] ,
569
+ [ '' , '' ] , // Implicit receiver
570
+ [ '`text`' , '`text` ' ] ,
571
+ [ 'text' , '`text` ' ] ,
555
572
] ) ;
556
573
} ) ;
557
574
@@ -565,21 +582,21 @@ describe('parser', () => {
565
582
] ,
566
583
[ 'tag' , 'tag' ] ,
567
584
[ 'tag' , '[nameSpan] tag' ] ,
568
- [ '' , '' ] ,
585
+ [ '' , '' ] , // Implicit receiver
569
586
[ '`before ${one} - ${two} - ${three} after`' , '`before ${one} - ${two} - ${three} after`' ] ,
570
- [ 'before ' , '' ] ,
587
+ [ 'before ' , '`before ' ] ,
571
588
[ 'one' , 'one' ] ,
572
589
[ 'one' , '[nameSpan] one' ] ,
573
- [ '' , '' ] ,
574
- [ ' - ' , '' ] ,
590
+ [ '' , '' ] , // Implicit receiver
591
+ [ ' - ' , ' - ' ] ,
575
592
[ 'two' , 'two' ] ,
576
593
[ 'two' , '[nameSpan] two' ] ,
577
- [ '' , '' ] ,
578
- [ ' - ' , '' ] ,
594
+ [ '' , '' ] , // Implicit receiver
595
+ [ ' - ' , ' - ' ] ,
579
596
[ 'three' , 'three' ] ,
580
597
[ 'three' , '[nameSpan] three' ] ,
581
- [ '' , '' ] ,
582
- [ ' after' , '' ] ,
598
+ [ '' , '' ] , // Implicit receiver
599
+ [ ' after' , ' after` ' ] ,
583
600
] ) ;
584
601
} ) ;
585
602
0 commit comments