7
7
*/
8
8
9
9
import { SchematicTestRunner , UnitTestTree } from '@angular-devkit/schematics/testing' ;
10
+ import { parse as parseJson } from 'jsonc-parser' ;
10
11
import { Schema as LibraryOptions } from '../library/schema' ;
11
12
import { Schema as WorkspaceOptions } from '../workspace/schema' ;
12
13
import { Schema as GenerateLibrarySchema } from './schema' ;
13
- import { parse as parseJson } from 'jsonc-parser' ;
14
14
15
15
// eslint-disable-next-line @typescript-eslint/no-explicit-any
16
16
function getJsonFileContent ( tree : UnitTestTree , path : string ) : any {
@@ -35,7 +35,6 @@ describe('Secondary Entrypoint Schematic', () => {
35
35
} ;
36
36
const libaryOptions : LibraryOptions = {
37
37
name : 'foo' ,
38
- entryFile : 'my-index' ,
39
38
standalone : true ,
40
39
skipPackageJson : false ,
41
40
skipTsConfig : false ,
@@ -45,12 +44,12 @@ describe('Secondary Entrypoint Schematic', () => {
45
44
let workspaceTree : UnitTestTree ;
46
45
beforeEach ( async ( ) => {
47
46
workspaceTree = await schematicRunner . runSchematic ( 'workspace' , workspaceOptions ) ;
47
+ workspaceTree = await schematicRunner . runSchematic ( 'library' , libaryOptions , workspaceTree ) ;
48
48
} ) ;
49
49
50
50
it ( 'should create correct files' , async ( ) => {
51
- workspaceTree = await schematicRunner . runSchematic ( 'library' , libaryOptions , workspaceTree ) ;
52
51
const tree = await schematicRunner . runSchematic (
53
- 'secondary ' ,
52
+ 'library-entrypoint ' ,
54
53
{ ...defaultOptions } ,
55
54
workspaceTree ,
56
55
) ;
@@ -60,47 +59,28 @@ describe('Secondary Entrypoint Schematic', () => {
60
59
jasmine . arrayContaining ( [
61
60
'/projects/foo/src/lib/foo-secondary/README.md' ,
62
61
'/projects/foo/src/lib/foo-secondary/ng-package.json' ,
63
- '/projects/foo/src/lib/foo-secondary/src/public-api.ts' ,
64
62
] ) ,
65
63
) ;
66
64
} ) ;
67
65
68
66
it ( 'should set correct main and secondary entrypoints in the README' , async ( ) => {
69
- workspaceTree = await schematicRunner . runSchematic ( 'library' , libaryOptions , workspaceTree ) ;
70
67
const tree = await schematicRunner . runSchematic (
71
- 'secondary ' ,
68
+ 'library-entrypoint ' ,
72
69
{ ...defaultOptions } ,
73
70
workspaceTree ,
74
71
) ;
75
72
const content = tree . readContent ( '/projects/foo/src/lib/foo-secondary/README.md' ) ;
76
73
expect ( content ) . toMatch ( '# foo/foo-secondary' ) ;
77
74
} ) ;
78
75
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
-
96
76
it ( 'should handle scope packages' , async ( ) => {
97
77
workspaceTree = await schematicRunner . runSchematic (
98
78
'library' ,
99
79
{ ...libaryOptions , name : '@scope/package' } ,
100
80
workspaceTree ,
101
81
) ;
102
82
const tree = await schematicRunner . runSchematic (
103
- 'secondary ' ,
83
+ 'library-entrypoint ' ,
104
84
{ ...defaultOptions , name : 'testing' , project : '@scope/package' } ,
105
85
workspaceTree ,
106
86
) ;
@@ -109,7 +89,6 @@ describe('Secondary Entrypoint Schematic', () => {
109
89
jasmine . arrayContaining ( [
110
90
'/projects/scope/package/src/lib/testing/README.md' ,
111
91
'/projects/scope/package/src/lib/testing/ng-package.json' ,
112
- '/projects/scope/package/src/lib/testing/src/public-api.ts' ,
113
92
] ) ,
114
93
) ;
115
94
} ) ;
@@ -121,7 +100,7 @@ describe('Secondary Entrypoint Schematic', () => {
121
100
workspaceTree ,
122
101
) ;
123
102
const tree = await schematicRunner . runSchematic (
124
- 'secondary ' ,
103
+ 'library-entrypoint ' ,
125
104
{ ...defaultOptions , name : 'testing' , project : '@scope/package' } ,
126
105
workspaceTree ,
127
106
) ;
@@ -150,14 +129,13 @@ describe('Secondary Entrypoint Schematic', () => {
150
129
} ) ,
151
130
) ;
152
131
const tree = await schematicRunner . runSchematic (
153
- 'secondary ' ,
132
+ 'library-entrypoint ' ,
154
133
{ ...defaultOptions , name : 'testing' , project : '@scope/package' } ,
155
134
workspaceTree ,
156
135
) ;
157
136
158
137
const tsConfigJson = getJsonFileContent ( tree , 'tsconfig.json' ) ;
159
138
expect ( tsConfigJson . compilerOptions . paths [ '@scope/package/testing' ] ) . toEqual ( [
160
- 'libs/*' ,
161
139
'./dist/scope/package/testing' ,
162
140
] ) ;
163
141
} ) ;
0 commit comments