(template: string)
| 60 | } |
| 61 | |
| 62 | function parse(template: string): ParseResult { |
| 63 | const position = template.indexOf('¦'); |
| 64 | if (position < 0) { |
| 65 | throw new Error(`Template "${template}" does not contain the cursor`); |
| 66 | } |
| 67 | template = template.replace('¦', ''); |
| 68 | const templateUrl = '/foo'; |
| 69 | return { |
| 70 | ...parseTemplate(template, templateUrl, { |
| 71 | // Set `leadingTriviaChars` and `preserveWhitespaces` such that whitespace is not stripped |
| 72 | // and fully accounted for in source spans. Without these flags the source spans can be |
| 73 | // inaccurate. |
| 74 | // Note: template parse options should be aligned with the `diagNodes` in |
| 75 | // `ComponentDecoratorHandler._parseTemplate`. |
| 76 | leadingTriviaChars: [], |
| 77 | preserveWhitespaces: true, |
| 78 | alwaysAttemptHtmlToR3AstConversion: true, |
| 79 | }), |
| 80 | position, |
| 81 | }; |
| 82 | } |
| 83 | |
| 84 | describe('getTargetAtPosition for template AST', () => { |
| 85 | it('should locate incomplete tag', () => { |
no test coverage detected