fix(language-service): Fix failing tests after merge (#32758)
https://github.com/angular/angular/pull/32653 and https://github.com/angular/angular/pull/32592 created a conflict in test that caused CI to turn red. This PR fixes the failing tests. PR Close #32758
This commit is contained in:
parent
5c2e890d76
commit
708ae4c8ef
@ -509,49 +509,41 @@ describe('diagnostics', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should report diagnostic for missing template or templateUrl', () => {
|
it('should report diagnostic for missing template or templateUrl', () => {
|
||||||
const fileName = mockHost.addCode(`
|
const fileName = '/app/app.component.ts';
|
||||||
|
const content = mockHost.override(fileName, `
|
||||||
|
import {Component} from '@angular/core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-example',
|
selector: 'app-example',
|
||||||
})
|
})
|
||||||
export class AppExample {}
|
export class AppComponent {}`);
|
||||||
|
|
||||||
@NgModule({
|
|
||||||
declarations: [AppExample],
|
|
||||||
})
|
|
||||||
export class AppModule {}`);
|
|
||||||
const diags = ngLS.getDiagnostics(fileName);
|
const diags = ngLS.getDiagnostics(fileName);
|
||||||
const missingTemplateError = diags.find(
|
expect(diags.length).toBe(1);
|
||||||
d => d.messageText === `Component 'AppExample' must have a template or templateUrl`);
|
const {file, messageText, start, length} = diags[0];
|
||||||
expect(missingTemplateError).toBeDefined();
|
expect(file !.fileName).toBe(fileName);
|
||||||
|
expect(messageText).toBe(`Component 'AppComponent' must have a template or templateUrl`);
|
||||||
const {start, length} = missingTemplateError !;
|
expect(start).toBe(content.indexOf(`@Component`) + 1);
|
||||||
const content = mockHost.getFileContent(fileName) !;
|
|
||||||
expect(start).toBe(content.lastIndexOf('Component'));
|
|
||||||
expect(length).toBe('Component'.length);
|
expect(length).toBe('Component'.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should report diagnostic for both template and templateUrl', () => {
|
it('should report diagnostic for both template and templateUrl', () => {
|
||||||
const fileName = mockHost.addCode(`
|
const fileName = '/app/app.component.ts';
|
||||||
|
const content = mockHost.override(fileName, `
|
||||||
|
import {Component} from '@angular/core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-example',
|
selector: 'app-example',
|
||||||
template: '<div></div>',
|
template: '<div></div>',
|
||||||
templateUrl: './example.html',
|
templateUrl: './test.ng',
|
||||||
})
|
})
|
||||||
export class AppExample {}
|
export class AppComponent {}`);
|
||||||
|
|
||||||
@NgModule({
|
|
||||||
declarations: [AppExample],
|
|
||||||
})
|
|
||||||
export class AppModule {}`);
|
|
||||||
const diags = ngLS.getDiagnostics(fileName);
|
const diags = ngLS.getDiagnostics(fileName);
|
||||||
const dupTemplateError = diags.find(
|
expect(diags.length).toBe(1);
|
||||||
d => d.messageText ===
|
const {file, messageText, start, length} = diags[0];
|
||||||
`Component 'AppExample' must not have both template and templateUrl`);
|
expect(file !.fileName).toBe(fileName);
|
||||||
expect(dupTemplateError).toBeDefined();
|
expect(messageText)
|
||||||
|
.toBe(`Component 'AppComponent' must not have both template and templateUrl`);
|
||||||
const {start, length} = dupTemplateError !;
|
expect(start).toBe(content.indexOf(`@Component`) + 1);
|
||||||
const content = mockHost.getFileContent(fileName) !;
|
|
||||||
expect(start).toBe(content.lastIndexOf('Component'));
|
|
||||||
expect(length).toBe('Component'.length);
|
expect(length).toBe('Component'.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user