diff --git a/packages/language-service/test/diagnostics_spec.ts b/packages/language-service/test/diagnostics_spec.ts index 82ea25bb30..810aefcbed 100644 --- a/packages/language-service/test/diagnostics_spec.ts +++ b/packages/language-service/test/diagnostics_spec.ts @@ -82,7 +82,7 @@ describe('diagnostics', () => { const {messageText, start, length} = diagnostics[0]; expect(messageText) .toBe( - 'Identifier \'$event\' is not defined. The component declaration, template variable declarations, and element references do not contain such a member'); + `Identifier '$event' is not defined. The component declaration, template variable declarations, and element references do not contain such a member`); const keyword = '$event'; expect(start).toBe(content.lastIndexOf(keyword)); expect(length).toBe(keyword.length); @@ -109,7 +109,7 @@ describe('diagnostics', () => { const {messageText, start, length} = diagnostics[0]; expect(messageText) .toBe( - 'Component \'MyComponent\' is not included in a module and will not be available inside a template. Consider adding it to a NgModule declaration.'); + `Component 'MyComponent' is not included in a module and will not be available inside a template. Consider adding it to a NgModule declaration.`); const content = mockHost.getFileContent(fileName) !; const keyword = '@Component'; expect(start).toBe(content.lastIndexOf(keyword) + 1); // exclude leading '@' @@ -175,7 +175,7 @@ describe('diagnostics', () => { expect(length).toBe(keyword.length); // messageText is a three-part chain const firstPart = messageText as ts.DiagnosticMessageChain; - expect(firstPart.messageText).toBe('Error during template compile of \'AppComponent\''); + expect(firstPart.messageText).toBe(`Error during template compile of 'AppComponent'`); const secondPart = firstPart.next !; expect(secondPart.messageText).toBe('Function expressions are not supported in decorators'); const thirdPart = secondPart.next !; @@ -475,6 +475,32 @@ describe('diagnostics', () => { `Module '"../node_modules/@angular/core/core"' has no exported member 'OpaqueToken'.`); }); + // https://github.com/angular/vscode-ng-language-service/issues/235 + // There is no easy fix for this issue currently due to the way template + // tokenization is done. In the example below, the whole string + // `\r\n{{line0}}\r\n{{line1}}\r\n{{line2}}` is tokenized as a whole, and then + // CR characters are stripped from it. Source span information is lost in the + // process. For more discussion, see the link above. + /* + it('should work correctly with CRLF endings', () => { + const fileName = '/app/test.ng'; + const content = mockHost.override(fileName, + '\r\n