@@ -34,15 +34,44 @@ describe('AngularAppEngine', () => {
3434 async ( ) => {
3535 @Component ( {
3636 standalone : true ,
37- selector : `app-home -${ locale } ` ,
38- template : `Home works ${ locale . toUpperCase ( ) } ` ,
37+ selector : `app-ssr -${ locale } ` ,
38+ template : `SSR works ${ locale . toUpperCase ( ) } ` ,
3939 } )
40- class HomeComponent { }
40+ class SSRComponent { }
41+
42+ @Component ( {
43+ standalone : true ,
44+ selector : `app-ssg-${ locale } ` ,
45+ template : `SSG works ${ locale . toUpperCase ( ) } ` ,
46+ } )
47+ class SSGComponent { }
4148
4249 setAngularAppTestingManifest (
43- [ { path : 'home' , component : HomeComponent } ] ,
44- [ { path : '**' , renderMode : RenderMode . Server } ] ,
50+ [
51+ { path : 'ssg' , component : SSGComponent } ,
52+ { path : 'ssr' , component : SSRComponent } ,
53+ ] ,
54+ [
55+ { path : 'ssg' , renderMode : RenderMode . Prerender } ,
56+ { path : '**' , renderMode : RenderMode . Server } ,
57+ ] ,
4558 '/' + locale ,
59+ {
60+ 'ssg/index.html' : {
61+ size : 25 ,
62+ hash : 'f799132d0a09e0fef93c68a12e443527700eb59e6f67fcb7854c3a60ff082fde' ,
63+ text : async ( ) => `<html>
64+ <head>
65+ <title>SSG page</title>
66+ <base href="/${ locale } " />
67+ </head>
68+ <body>
69+ SSG works ${ locale . toUpperCase ( ) }
70+ </body>
71+ </html>
72+ ` ,
73+ } ,
74+ } ,
4675 ) ;
4776
4877 return {
@@ -58,29 +87,41 @@ describe('AngularAppEngine', () => {
5887 appEngine = new AngularAppEngine ( ) ;
5988 } ) ;
6089
61- describe ( 'render ' , ( ) => {
90+ describe ( 'handle ' , ( ) => {
6291 it ( 'should return null for requests to unknown pages' , async ( ) => {
6392 const request = new Request ( 'https://example.com/unknown/page' ) ;
6493 const response = await appEngine . handle ( request ) ;
6594 expect ( response ) . toBeNull ( ) ;
6695 } ) ;
6796
6897 it ( 'should return null for requests with unknown locales' , async ( ) => {
69- const request = new Request ( 'https://example.com/es/home ' ) ;
98+ const request = new Request ( 'https://example.com/es/ssr ' ) ;
7099 const response = await appEngine . handle ( request ) ;
71100 expect ( response ) . toBeNull ( ) ;
72101 } ) ;
73102
74103 it ( 'should return a rendered page with correct locale' , async ( ) => {
75- const request = new Request ( 'https://example.com/it/home ' ) ;
104+ const request = new Request ( 'https://example.com/it/ssr ' ) ;
76105 const response = await appEngine . handle ( request ) ;
77- expect ( await response ?. text ( ) ) . toContain ( 'Home works IT' ) ;
106+ expect ( await response ?. text ( ) ) . toContain ( 'SSR works IT' ) ;
78107 } ) ;
79108
80109 it ( 'should correctly render the content when the URL ends with "index.html" with correct locale' , async ( ) => {
81- const request = new Request ( 'https://example.com/it/home/index.html' ) ;
110+ const request = new Request ( 'https://example.com/it/ssr/index.html' ) ;
111+ const response = await appEngine . handle ( request ) ;
112+ expect ( await response ?. text ( ) ) . toContain ( 'SSR works IT' ) ;
113+ } ) ;
114+
115+ it ( 'should return a serve prerendered page with correct locale' , async ( ) => {
116+ const request = new Request ( 'https://example.com/it/ssg' ) ;
117+ const response = await appEngine . handle ( request ) ;
118+ expect ( await response ?. text ( ) ) . toContain ( 'SSG works IT' ) ;
119+ } ) ;
120+
121+ it ( 'should correctly serve the prerendered content when the URL ends with "index.html" with correct locale' , async ( ) => {
122+ const request = new Request ( 'https://example.com/it/ssg/index.html' ) ;
82123 const response = await appEngine . handle ( request ) ;
83- expect ( await response ?. text ( ) ) . toContain ( 'Home works IT' ) ;
124+ expect ( await response ?. text ( ) ) . toContain ( 'SSG works IT' ) ;
84125 } ) ;
85126
86127 it ( 'should return null for requests to unknown pages in a locale' , async ( ) => {
0 commit comments