test(compiler-cli): ensure indexer tests are not brittle to case-sensitivity (#36859)

These tests were matching file-paths against what is retrieved from the
TS compiler. But the TS compiler paths have been canonicalised, so the
tests were brittle on case-insensitive file-systems.

PR Close #36859
This commit is contained in:
Pete Bacon Darwin 2020-05-06 22:20:50 +01:00 committed by Alex Rickabaugh
parent a10c126692
commit 8ce38cac0d
3 changed files with 8 additions and 8 deletions

View File

@ -23,7 +23,7 @@ runInEachFileSystem(() => {
boundTemplate,
templateMeta: {
isInline: false,
file: new ParseSourceFile('<div></div>', util.getTestFilePath()),
file: new ParseSourceFile('<div></div>', declaration.getSourceFile().fileName),
},
});
@ -34,7 +34,7 @@ runInEachFileSystem(() => {
boundTemplate,
templateMeta: {
isInline: false,
file: new ParseSourceFile('<div></div>', util.getTestFilePath()),
file: new ParseSourceFile('<div></div>', declaration.getSourceFile().fileName),
},
},
]));

View File

@ -25,7 +25,7 @@ function populateContext(
boundTemplate,
templateMeta: {
isInline,
file: new ParseSourceFile(template, util.getTestFilePath()),
file: new ParseSourceFile(template, component.getSourceFile().fileName),
},
});
}
@ -45,12 +45,12 @@ runInEachFileSystem(() => {
expect(info).toEqual({
name: 'C',
selector: 'c-selector',
file: new ParseSourceFile('class C {}', util.getTestFilePath()),
file: new ParseSourceFile('class C {}', decl.getSourceFile().fileName),
template: {
identifiers: getTemplateIdentifiers(util.getBoundTemplate('<div>{{foo}}</div>')),
usedComponents: new Set(),
isInline: false,
file: new ParseSourceFile('<div>{{foo}}</div>', util.getTestFilePath()),
file: new ParseSourceFile('<div>{{foo}}</div>', decl.getSourceFile().fileName),
}
});
});
@ -69,7 +69,7 @@ runInEachFileSystem(() => {
const info = analysis.get(decl);
expect(info).toBeDefined();
expect(info!.template.file)
.toEqual(new ParseSourceFile('class C {}', util.getTestFilePath()));
.toEqual(new ParseSourceFile('class C {}', decl.getSourceFile().fileName));
});
it('should give external templates their own source file', () => {
@ -84,7 +84,7 @@ runInEachFileSystem(() => {
const info = analysis.get(decl);
expect(info).toBeDefined();
expect(info!.template.file)
.toEqual(new ParseSourceFile('<div>{{foo}}</div>', util.getTestFilePath()));
.toEqual(new ParseSourceFile('<div>{{foo}}</div>', decl.getSourceFile().fileName));
});
it('should emit used components', () => {

View File

@ -16,7 +16,7 @@ import {getDeclaration, makeProgram} from '../../testing';
import {ComponentMeta} from '../src/context';
/** Dummy file URL */
export function getTestFilePath(): AbsoluteFsPath {
function getTestFilePath(): AbsoluteFsPath {
return absoluteFrom('/TEST_FILE.ts');
}