test(ngcc): cleanup entry-point bundle testcases (#34415)
There was an issue with the program under test and two tests with the same description, this has been fixed. PR Close #34415
This commit is contained in:
parent
a186dbc1d4
commit
12444a8afc
|
@ -134,7 +134,7 @@ runInEachFileSystem(() => {
|
||||||
{name: _('/node_modules/internal/src/index.d.ts'), contents: ''},
|
{name: _('/node_modules/internal/src/index.d.ts'), contents: ''},
|
||||||
{
|
{
|
||||||
name: _('/node_modules/internal/src/internal.d.ts'),
|
name: _('/node_modules/internal/src/internal.d.ts'),
|
||||||
contents: 'export declare function internal();'
|
contents: 'export declare class Internal {}'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: _('/node_modules/internal/esm2015/index.js'),
|
name: _('/node_modules/internal/esm2015/index.js'),
|
||||||
|
@ -146,7 +146,7 @@ runInEachFileSystem(() => {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: _('/node_modules/internal/esm2015/src/internal.js'),
|
name: _('/node_modules/internal/esm2015/src/internal.js'),
|
||||||
contents: 'export function internal();'
|
contents: 'export class Internal {}'
|
||||||
},
|
},
|
||||||
|
|
||||||
// A package with a secondary entry-point that has source files in a different tree
|
// A package with a secondary entry-point that has source files in a different tree
|
||||||
|
@ -210,74 +210,75 @@ runInEachFileSystem(() => {
|
||||||
].map(p => absoluteFrom(p).toString())));
|
].map(p => absoluteFrom(p).toString())));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should include equivalently named, internally imported, src files in the typings program, if `mirrorDtsFromSrc` is true',
|
describe(
|
||||||
() => {
|
'including equivalently named, internally imported, src files in the typings program',
|
||||||
setupMockFileSystem();
|
() => {
|
||||||
const fs = getFileSystem();
|
it('does include internal .d.ts files if `mirrorDtsFromSrc` is true', () => {
|
||||||
const entryPoint: EntryPoint = {
|
setupMockFileSystem();
|
||||||
name: 'test',
|
const fs = getFileSystem();
|
||||||
packageJson: {name: 'test'},
|
const entryPoint: EntryPoint = {
|
||||||
package: absoluteFrom('/node_modules/test'),
|
name: 'test',
|
||||||
path: absoluteFrom('/node_modules/test'),
|
packageJson: {name: 'test'},
|
||||||
typings: absoluteFrom('/node_modules/test/index.d.ts'),
|
package: absoluteFrom('/node_modules/test'),
|
||||||
compiledByAngular: true,
|
path: absoluteFrom('/node_modules/test'),
|
||||||
ignoreMissingDependencies: false,
|
typings: absoluteFrom('/node_modules/test/index.d.ts'),
|
||||||
generateDeepReexports: false,
|
compiledByAngular: true,
|
||||||
};
|
ignoreMissingDependencies: false,
|
||||||
const esm5bundle = makeEntryPointBundle(
|
generateDeepReexports: false,
|
||||||
fs, entryPoint, './index.js', false, 'esm5', /* transformDts */ true,
|
};
|
||||||
/* pathMappings */ undefined, /* mirrorDtsFromSrc */ true);
|
const esm5bundle = makeEntryPointBundle(
|
||||||
expect(esm5bundle.src.program.getSourceFiles().map(sf => sf.fileName))
|
fs, entryPoint, './index.js', false, 'esm5', /* transformDts */ true,
|
||||||
.toContain(absoluteFrom('/node_modules/test/internal.js'));
|
/* pathMappings */ undefined, /* mirrorDtsFromSrc */ true);
|
||||||
expect(esm5bundle.dts !.program.getSourceFiles().map(sf => sf.fileName))
|
expect(esm5bundle.src.program.getSourceFiles().map(sf => sf.fileName))
|
||||||
.toContain(absoluteFrom('/node_modules/test/internal.d.ts'));
|
.toContain(absoluteFrom('/node_modules/test/internal.js'));
|
||||||
});
|
expect(esm5bundle.dts !.program.getSourceFiles().map(sf => sf.fileName))
|
||||||
|
.toContain(absoluteFrom('/node_modules/test/internal.d.ts'));
|
||||||
|
});
|
||||||
|
|
||||||
it('should include equivalently named, internally imported, src files in the typings program, if `mirrorDtsFromSrc` is true',
|
it('should work when the .d.ts files are in a different tree than the sources', () => {
|
||||||
() => {
|
setupMockFileSystem();
|
||||||
setupMockFileSystem();
|
const fs = getFileSystem();
|
||||||
const fs = getFileSystem();
|
const entryPoint: EntryPoint = {
|
||||||
const entryPoint: EntryPoint = {
|
name: 'internal',
|
||||||
name: 'internal',
|
packageJson: {name: 'internal'},
|
||||||
packageJson: {name: 'internal'},
|
package: absoluteFrom('/node_modules/internal'),
|
||||||
package: absoluteFrom('/node_modules/internal'),
|
path: absoluteFrom('/node_modules/internal'),
|
||||||
path: absoluteFrom('/node_modules/internal'),
|
typings: absoluteFrom('/node_modules/internal/index.d.ts'),
|
||||||
typings: absoluteFrom('/node_modules/internal/index.d.ts'),
|
compiledByAngular: true,
|
||||||
compiledByAngular: true,
|
ignoreMissingDependencies: false,
|
||||||
ignoreMissingDependencies: false,
|
generateDeepReexports: false,
|
||||||
generateDeepReexports: false,
|
};
|
||||||
};
|
const esm5bundle = makeEntryPointBundle(
|
||||||
const esm5bundle = makeEntryPointBundle(
|
fs, entryPoint, './esm2015/index.js', false, 'esm2015', /* transformDts */ true,
|
||||||
fs, entryPoint, './esm2015/index.js', false, 'esm2015', /* transformDts */ true,
|
/* pathMappings */ undefined, /* mirrorDtsFromSrc */ true);
|
||||||
/* pathMappings */ undefined, /* mirrorDtsFromSrc */ true);
|
expect(esm5bundle.src.program.getSourceFiles().map(sf => sf.fileName))
|
||||||
expect(esm5bundle.src.program.getSourceFiles().map(sf => sf.fileName))
|
.toContain(absoluteFrom('/node_modules/internal/esm2015/src/internal.js'));
|
||||||
.toContain(absoluteFrom('/node_modules/internal/esm2015/src/internal.js'));
|
expect(esm5bundle.dts !.program.getSourceFiles().map(sf => sf.fileName))
|
||||||
expect(esm5bundle.dts !.program.getSourceFiles().map(sf => sf.fileName))
|
.toContain(absoluteFrom('/node_modules/internal/src/internal.d.ts'));
|
||||||
.toContain(absoluteFrom('/node_modules/internal/src/internal.d.ts'));
|
});
|
||||||
});
|
|
||||||
|
|
||||||
it('should ignore, internally imported, src files in the typings program, if `mirrorDtsFromSrc` is false',
|
it('ignores internal .d.ts files if `mirrorDtsFromSrc` is false', () => {
|
||||||
() => {
|
setupMockFileSystem();
|
||||||
setupMockFileSystem();
|
const fs = getFileSystem();
|
||||||
const fs = getFileSystem();
|
const entryPoint: EntryPoint = {
|
||||||
const entryPoint: EntryPoint = {
|
name: 'test',
|
||||||
name: 'test',
|
packageJson: {name: 'test'},
|
||||||
packageJson: {name: 'test'},
|
package: absoluteFrom('/node_modules/test'),
|
||||||
package: absoluteFrom('/node_modules/test'),
|
path: absoluteFrom('/node_modules/test'),
|
||||||
path: absoluteFrom('/node_modules/test'),
|
typings: absoluteFrom('/node_modules/test/index.d.ts'),
|
||||||
typings: absoluteFrom('/node_modules/test/index.d.ts'),
|
compiledByAngular: true,
|
||||||
compiledByAngular: true,
|
ignoreMissingDependencies: false,
|
||||||
ignoreMissingDependencies: false,
|
generateDeepReexports: false,
|
||||||
generateDeepReexports: false,
|
};
|
||||||
};
|
const esm5bundle = makeEntryPointBundle(
|
||||||
const esm5bundle = makeEntryPointBundle(
|
fs, entryPoint, './index.js', false, 'esm5', /* transformDts */ true,
|
||||||
fs, entryPoint, './index.js', false, 'esm5', /* transformDts */ true,
|
/* pathMappings */ undefined, /* mirrorDtsFromSrc */ false);
|
||||||
/* pathMappings */ undefined, /* mirrorDtsFromSrc */ false);
|
expect(esm5bundle.src.program.getSourceFiles().map(sf => sf.fileName))
|
||||||
expect(esm5bundle.src.program.getSourceFiles().map(sf => sf.fileName))
|
.toContain(absoluteFrom('/node_modules/test/internal.js'));
|
||||||
.toContain(absoluteFrom('/node_modules/test/internal.js'));
|
expect(esm5bundle.dts !.program.getSourceFiles().map(sf => sf.fileName))
|
||||||
expect(esm5bundle.dts !.program.getSourceFiles().map(sf => sf.fileName))
|
.not.toContain(absoluteFrom('/node_modules/test/internal.d.ts'));
|
||||||
.not.toContain(absoluteFrom('/node_modules/test/internal.d.ts'));
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set the `rootDir` to the package path not the entry-point path', () => {
|
it('should set the `rootDir` to the package path not the entry-point path', () => {
|
||||||
setupMockFileSystem();
|
setupMockFileSystem();
|
||||||
|
|
Loading…
Reference in New Issue