77 */
88
99import { SchematicTestRunner , UnitTestTree } from '@angular-devkit/schematics/testing' ;
10+ import { parse as parseJson } from 'jsonc-parser' ;
1011import { Schema as LibraryOptions } from '../library/schema' ;
1112import { Schema as WorkspaceOptions } from '../workspace/schema' ;
1213import { Schema as GenerateLibrarySchema } from './schema' ;
13- import { parse as parseJson } from 'jsonc-parser' ;
1414
1515// eslint-disable-next-line @typescript-eslint/no-explicit-any
1616function getJsonFileContent ( tree : UnitTestTree , path : string ) : any {
@@ -35,7 +35,6 @@ describe('Secondary Entrypoint Schematic', () => {
3535 } ;
3636 const libaryOptions : LibraryOptions = {
3737 name : 'foo' ,
38- entryFile : 'my-index' ,
3938 standalone : true ,
4039 skipPackageJson : false ,
4140 skipTsConfig : false ,
@@ -45,12 +44,12 @@ describe('Secondary Entrypoint Schematic', () => {
4544 let workspaceTree : UnitTestTree ;
4645 beforeEach ( async ( ) => {
4746 workspaceTree = await schematicRunner . runSchematic ( 'workspace' , workspaceOptions ) ;
47+ workspaceTree = await schematicRunner . runSchematic ( 'library' , libaryOptions , workspaceTree ) ;
4848 } ) ;
4949
5050 it ( 'should create correct files' , async ( ) => {
51- workspaceTree = await schematicRunner . runSchematic ( 'library' , libaryOptions , workspaceTree ) ;
5251 const tree = await schematicRunner . runSchematic (
53- 'secondary ' ,
52+ 'library-entrypoint ' ,
5453 { ...defaultOptions } ,
5554 workspaceTree ,
5655 ) ;
@@ -60,47 +59,28 @@ describe('Secondary Entrypoint Schematic', () => {
6059 jasmine . arrayContaining ( [
6160 '/projects/foo/src/lib/foo-secondary/README.md' ,
6261 '/projects/foo/src/lib/foo-secondary/ng-package.json' ,
63- '/projects/foo/src/lib/foo-secondary/src/public-api.ts' ,
6462 ] ) ,
6563 ) ;
6664 } ) ;
6765
6866 it ( 'should set correct main and secondary entrypoints in the README' , async ( ) => {
69- workspaceTree = await schematicRunner . runSchematic ( 'library' , libaryOptions , workspaceTree ) ;
7067 const tree = await schematicRunner . runSchematic (
71- 'secondary ' ,
68+ 'library-entrypoint ' ,
7269 { ...defaultOptions } ,
7370 workspaceTree ,
7471 ) ;
7572 const content = tree . readContent ( '/projects/foo/src/lib/foo-secondary/README.md' ) ;
7673 expect ( content ) . toMatch ( '# foo/foo-secondary' ) ;
7774 } ) ;
7875
79- it ( 'should set a custom entryfile' , async ( ) => {
80- workspaceTree = await schematicRunner . runSchematic ( 'library' , libaryOptions , workspaceTree ) ;
81- const tree = await schematicRunner . runSchematic (
82- 'secondary' ,
83- { ...defaultOptions , entryFile : 'my-index' } ,
84- workspaceTree ,
85- ) ;
86- const files = tree . files ;
87- expect ( files ) . toEqual (
88- jasmine . arrayContaining ( [
89- '/projects/foo/src/lib/foo-secondary/README.md' ,
90- '/projects/foo/src/lib/foo-secondary/ng-package.json' ,
91- '/projects/foo/src/lib/foo-secondary/src/my-index.ts' ,
92- ] ) ,
93- ) ;
94- } ) ;
95-
9676 it ( 'should handle scope packages' , async ( ) => {
9777 workspaceTree = await schematicRunner . runSchematic (
9878 'library' ,
9979 { ...libaryOptions , name : '@scope/package' } ,
10080 workspaceTree ,
10181 ) ;
10282 const tree = await schematicRunner . runSchematic (
103- 'secondary ' ,
83+ 'library-entrypoint ' ,
10484 { ...defaultOptions , name : 'testing' , project : '@scope/package' } ,
10585 workspaceTree ,
10686 ) ;
@@ -109,7 +89,6 @@ describe('Secondary Entrypoint Schematic', () => {
10989 jasmine . arrayContaining ( [
11090 '/projects/scope/package/src/lib/testing/README.md' ,
11191 '/projects/scope/package/src/lib/testing/ng-package.json' ,
112- '/projects/scope/package/src/lib/testing/src/public-api.ts' ,
11392 ] ) ,
11493 ) ;
11594 } ) ;
@@ -121,7 +100,7 @@ describe('Secondary Entrypoint Schematic', () => {
121100 workspaceTree ,
122101 ) ;
123102 const tree = await schematicRunner . runSchematic (
124- 'secondary ' ,
103+ 'library-entrypoint ' ,
125104 { ...defaultOptions , name : 'testing' , project : '@scope/package' } ,
126105 workspaceTree ,
127106 ) ;
@@ -150,14 +129,13 @@ describe('Secondary Entrypoint Schematic', () => {
150129 } ) ,
151130 ) ;
152131 const tree = await schematicRunner . runSchematic (
153- 'secondary ' ,
132+ 'library-entrypoint ' ,
154133 { ...defaultOptions , name : 'testing' , project : '@scope/package' } ,
155134 workspaceTree ,
156135 ) ;
157136
158137 const tsConfigJson = getJsonFileContent ( tree , 'tsconfig.json' ) ;
159138 expect ( tsConfigJson . compilerOptions . paths [ '@scope/package/testing' ] ) . toEqual ( [
160- 'libs/*' ,
161139 './dist/scope/package/testing' ,
162140 ] ) ;
163141 } ) ;
0 commit comments