@@ -107,6 +107,11 @@ describe('Migration to v6', () => {
107
107
tree . create ( '/src/favicon.ico' , '' ) ;
108
108
} ) ;
109
109
110
+ // tslint:disable-next-line:no-any
111
+ function getConfig ( tree : UnitTestTree ) : any {
112
+ return JSON . parse ( tree . readContent ( configPath ) ) ;
113
+ }
114
+
110
115
describe ( 'file creation/deletion' , ( ) => {
111
116
it ( 'should delete the old config file' , ( ) => {
112
117
tree . create ( oldConfigPath , JSON . stringify ( baseConfig , null , 2 ) ) ;
@@ -123,11 +128,6 @@ describe('Migration to v6', () => {
123
128
} ) ;
124
129
125
130
describe ( 'config file contents' , ( ) => {
126
- // tslint:disable-next-line:no-any
127
- function getConfig ( tree : UnitTestTree ) : any {
128
- return JSON . parse ( tree . readContent ( configPath ) ) ;
129
- }
130
-
131
131
it ( 'should set root values' , ( ) => {
132
132
tree . create ( oldConfigPath , JSON . stringify ( baseConfig , null , 2 ) ) ;
133
133
tree = schematicRunner . runSchematic ( 'migration-01' , defaultOptions , tree ) ;
@@ -720,4 +720,55 @@ describe('Migration to v6', () => {
720
720
expect ( blacklist ) . toEqual ( [ ] ) ;
721
721
} ) ;
722
722
} ) ;
723
+
724
+ describe ( 'server/universal apps' , ( ) => {
725
+ let serverApp ;
726
+ beforeEach ( ( ) => {
727
+ serverApp = {
728
+ platform : 'server' ,
729
+ root : 'src' ,
730
+ outDir : 'dist/server' ,
731
+ assets : [
732
+ 'assets' ,
733
+ 'favicon.ico' ,
734
+ ] ,
735
+ index : 'index.html' ,
736
+ main : 'main.server.ts' ,
737
+ test : 'test.ts' ,
738
+ tsconfig : 'tsconfig.server.json' ,
739
+ testTsconfig : 'tsconfig.spec.json' ,
740
+ prefix : 'app' ,
741
+ styles : [
742
+ 'styles.css' ,
743
+ ] ,
744
+ scripts : [ ] ,
745
+ environmentSource : 'environments/environment.ts' ,
746
+ environments : {
747
+ dev : 'environments/environment.ts' ,
748
+ prod : 'environments/environment.prod.ts' ,
749
+ } ,
750
+ } ;
751
+ baseConfig . apps . push ( serverApp ) ;
752
+ } ) ;
753
+
754
+ it ( 'should not create a separate app for server apps' , ( ) => {
755
+ tree . create ( oldConfigPath , JSON . stringify ( baseConfig , null , 2 ) ) ;
756
+ tree = schematicRunner . runSchematic ( 'migration-01' , defaultOptions , tree ) ;
757
+ const config = getConfig ( tree ) ;
758
+ const appCount = Object . keys ( config . projects ) . length ;
759
+ expect ( appCount ) . toEqual ( 2 ) ;
760
+ } ) ;
761
+
762
+ it ( 'should create a server target' , ( ) => {
763
+ tree . create ( oldConfigPath , JSON . stringify ( baseConfig , null , 2 ) ) ;
764
+ tree = schematicRunner . runSchematic ( 'migration-01' , defaultOptions , tree ) ;
765
+ const config = getConfig ( tree ) ;
766
+ const target = config . projects . foo . architect . server ;
767
+ expect ( target ) . toBeDefined ( ) ;
768
+ expect ( target . builder ) . toEqual ( '@angular-devkit/build-angular:server' ) ;
769
+ expect ( target . options . outputPath ) . toEqual ( 'dist/server' ) ;
770
+ expect ( target . options . main ) . toEqual ( 'main.server.ts' ) ;
771
+ expect ( target . options . tsConfig ) . toEqual ( 'tsconfig.server.json' ) ;
772
+ } ) ;
773
+ } ) ;
723
774
} ) ;
0 commit comments