test(schematics): add test for relatively importing src directory of another library
This commit is contained in:
parent
dd1a7f5c3a
commit
5daffc3cc7
@ -340,7 +340,7 @@ describe('Enforce Module Boundaries', () => {
|
|||||||
tags: [],
|
tags: [],
|
||||||
implicitDependencies: [],
|
implicitDependencies: [],
|
||||||
architect: {},
|
architect: {},
|
||||||
files: [`libs/mylib/src/main.ts`, `libs/mylib/src/other/index.ts`],
|
files: [`libs/mylib/src/main.ts`, `libs/mylib/other/index.ts`],
|
||||||
fileMTimes: {
|
fileMTimes: {
|
||||||
'libs/mylib/src/main.ts': 1,
|
'libs/mylib/src/main.ts': 1,
|
||||||
'libs/mylib/src/other/index.ts': 1
|
'libs/mylib/src/other/index.ts': 1
|
||||||
@ -387,6 +387,43 @@ describe('Enforce Module Boundaries', () => {
|
|||||||
'library imports must start with @mycompany/'
|
'library imports must start with @mycompany/'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should error when relatively importing the src directory of another library', () => {
|
||||||
|
const failures = runRule(
|
||||||
|
{},
|
||||||
|
`${process.cwd()}/proj/libs/mylib/src/main.ts`,
|
||||||
|
'import "../../other/src"',
|
||||||
|
[
|
||||||
|
{
|
||||||
|
name: 'mylibName',
|
||||||
|
root: 'libs/mylib',
|
||||||
|
type: ProjectType.lib,
|
||||||
|
tags: [],
|
||||||
|
implicitDependencies: [],
|
||||||
|
architect: {},
|
||||||
|
files: [`libs/mylib/src/main.ts`],
|
||||||
|
fileMTimes: {
|
||||||
|
'libs/mylib/src/main.ts': 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'otherName',
|
||||||
|
root: 'libs/other',
|
||||||
|
type: ProjectType.lib,
|
||||||
|
tags: [],
|
||||||
|
implicitDependencies: [],
|
||||||
|
architect: {},
|
||||||
|
files: ['libs/other/src/index.ts'],
|
||||||
|
fileMTimes: {
|
||||||
|
'libs/other/src/main.ts': 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
);
|
||||||
|
expect(failures[0].getFailure()).toEqual(
|
||||||
|
'library imports must start with @mycompany/'
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should error on absolute imports into libraries without using the npm scope', () => {
|
it('should error on absolute imports into libraries without using the npm scope', () => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user