@@ -19,6 +19,9 @@ describe('Universal Schematic', () => {
19
19
const defaultOptions : UniversalOptions = {
20
20
clientProject : 'bar' ,
21
21
} ;
22
+ const workspaceUniversalOptions : UniversalOptions = {
23
+ clientProject : 'workspace' ,
24
+ } ;
22
25
23
26
const workspaceOptions : WorkspaceOptions = {
24
27
name : 'workspace' ,
@@ -36,10 +39,22 @@ describe('Universal Schematic', () => {
36
39
skipPackageJson : false ,
37
40
} ;
38
41
42
+ const initialWorkspaceAppOptions : ApplicationOptions = {
43
+ name : 'workspace' ,
44
+ projectRoot : '' ,
45
+ inlineStyle : false ,
46
+ inlineTemplate : false ,
47
+ routing : false ,
48
+ style : 'css' ,
49
+ skipTests : false ,
50
+ skipPackageJson : false ,
51
+ } ;
52
+
39
53
let appTree : UnitTestTree ;
40
54
41
55
beforeEach ( ( ) => {
42
56
appTree = schematicRunner . runSchematic ( 'workspace' , workspaceOptions ) ;
57
+ appTree = schematicRunner . runSchematic ( 'application' , initialWorkspaceAppOptions , appTree ) ;
43
58
appTree = schematicRunner . runSchematic ( 'application' , appOptions , appTree ) ;
44
59
} ) ;
45
60
@@ -57,9 +72,30 @@ describe('Universal Schematic', () => {
57
72
expect ( contents ) . toMatch ( / e x p o r t { A p p S e r v e r M o d u l e } f r o m ' \. \/ a p p \/ a p p \. s e r v e r \. m o d u l e ' / ) ;
58
73
} ) ;
59
74
60
- it ( 'should create a tsconfig file' , ( ) => {
75
+ it ( 'should create a tsconfig file for the workspace project' , ( ) => {
76
+ const tree = schematicRunner . runSchematic ( 'universal' , workspaceUniversalOptions , appTree ) ;
77
+ const filePath = '/src/tsconfig.server.json' ;
78
+ expect ( tree . exists ( filePath ) ) . toEqual ( true ) ;
79
+ const contents = tree . readContent ( filePath ) ;
80
+ expect ( JSON . parse ( contents ) ) . toEqual ( {
81
+ extends : './tsconfig.app.json' ,
82
+ compilerOptions : {
83
+ outDir : '../out-tsc/app-server' ,
84
+ baseUrl : '.' ,
85
+ module : 'commonjs' ,
86
+ } ,
87
+ angularCompilerOptions : {
88
+ entryModule : 'app/app.server.module#AppServerModule' ,
89
+ } ,
90
+ } ) ;
91
+ const angularConfig = JSON . parse ( tree . readContent ( 'angular.json' ) ) ;
92
+ expect ( angularConfig . projects . workspace . architect . server . options . tsConfig )
93
+ . toEqual ( 'src/tsconfig.server.json' ) ;
94
+ } ) ;
95
+
96
+ it ( 'should create a tsconfig file for a generated application' , ( ) => {
61
97
const tree = schematicRunner . runSchematic ( 'universal' , defaultOptions , appTree ) ;
62
- const filePath = '/projects/bar/src/ tsconfig.server.json' ;
98
+ const filePath = '/projects/bar/tsconfig.server.json' ;
63
99
expect ( tree . exists ( filePath ) ) . toEqual ( true ) ;
64
100
const contents = tree . readContent ( filePath ) ;
65
101
expect ( JSON . parse ( contents ) ) . toEqual ( {
@@ -70,9 +106,12 @@ describe('Universal Schematic', () => {
70
106
module : 'commonjs' ,
71
107
} ,
72
108
angularCompilerOptions : {
73
- entryModule : 'app/app.server.module#AppServerModule' ,
109
+ entryModule : 'src/ app/app.server.module#AppServerModule' ,
74
110
} ,
75
111
} ) ;
112
+ const angularConfig = JSON . parse ( tree . readContent ( 'angular.json' ) ) ;
113
+ expect ( angularConfig . projects . bar . architect . server . options . tsConfig )
114
+ . toEqual ( 'projects/bar/tsconfig.server.json' ) ;
76
115
} ) ;
77
116
78
117
it ( 'should add dependency: @angular/platform-server' , ( ) => {
@@ -93,7 +132,7 @@ describe('Universal Schematic', () => {
93
132
const opts = arch . server . options ;
94
133
expect ( opts . outputPath ) . toEqual ( 'dist/bar-server' ) ;
95
134
expect ( opts . main ) . toEqual ( 'projects/bar/src/main.server.ts' ) ;
96
- expect ( opts . tsConfig ) . toEqual ( 'projects/bar/src/ tsconfig.server.json' ) ;
135
+ expect ( opts . tsConfig ) . toEqual ( 'projects/bar/tsconfig.server.json' ) ;
97
136
} ) ;
98
137
99
138
it ( 'should add a server transition to BrowerModule import' , ( ) => {
0 commit comments