@@ -18,6 +18,7 @@ import {
1818 PropertyRead ,
1919 TemplateBinding ,
2020 VariableBinding ,
21+ TemplateLiteral ,
2122} from '@angular/compiler/src/expression_parser/ast' ;
2223import { Lexer } from '@angular/compiler/src/expression_parser/lexer' ;
2324import { Parser , SplitInterpolation } from '@angular/compiler/src/expression_parser/parser' ;
@@ -528,18 +529,34 @@ describe('parser', () => {
528529 expect ( unparseWithSpan ( ast ) ) . toContain ( [ 'a.b = c' , '[nameSpan] b' ] ) ;
529530 } ) ;
530531
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' , ( ) => {
532542 const ast = parseAction ( '`before ${one} - ${two} - ${three} after`' ) ;
533543 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+ ] ) ;
543560 } ) ;
544561
545562 it ( 'should record spans for tagged template literal with no interpolations' , ( ) => {
@@ -549,9 +566,9 @@ describe('parser', () => {
549566 [ 'tag`text`' , 'tag`text`' ] ,
550567 [ 'tag' , 'tag' ] ,
551568 [ 'tag' , '[nameSpan] tag' ] ,
552- [ '' , '' ] ,
553- [ '`text`' , '' ] ,
554- [ 'text' , '' ] ,
569+ [ '' , '' ] , // Implicit receiver
570+ [ '`text`' , '`text` ' ] ,
571+ [ 'text' , '`text` ' ] ,
555572 ] ) ;
556573 } ) ;
557574
@@ -565,21 +582,21 @@ describe('parser', () => {
565582 ] ,
566583 [ 'tag' , 'tag' ] ,
567584 [ 'tag' , '[nameSpan] tag' ] ,
568- [ '' , '' ] ,
585+ [ '' , '' ] , // Implicit receiver
569586 [ '`before ${one} - ${two} - ${three} after`' , '`before ${one} - ${two} - ${three} after`' ] ,
570- [ 'before ' , '' ] ,
587+ [ 'before ' , '`before ' ] ,
571588 [ 'one' , 'one' ] ,
572589 [ 'one' , '[nameSpan] one' ] ,
573- [ '' , '' ] ,
574- [ ' - ' , '' ] ,
590+ [ '' , '' ] , // Implicit receiver
591+ [ ' - ' , ' - ' ] ,
575592 [ 'two' , 'two' ] ,
576593 [ 'two' , '[nameSpan] two' ] ,
577- [ '' , '' ] ,
578- [ ' - ' , '' ] ,
594+ [ '' , '' ] , // Implicit receiver
595+ [ ' - ' , ' - ' ] ,
579596 [ 'three' , 'three' ] ,
580597 [ 'three' , '[nameSpan] three' ] ,
581- [ '' , '' ] ,
582- [ ' after' , '' ] ,
598+ [ '' , '' ] , // Implicit receiver
599+ [ ' after' , ' after` ' ] ,
583600 ] ) ;
584601 } ) ;
585602
0 commit comments