@@ -160,6 +160,66 @@ describe('AngularAppEngine', () => {
160160 } ) ;
161161 } ) ;
162162
163+ describe ( 'Localized app with single locale' , ( ) => {
164+ beforeAll ( ( ) => {
165+ setAngularAppEngineManifest ( {
166+ entryPoints : {
167+ it : createEntryPoint ( 'it' ) ,
168+ } ,
169+ supportedLocales : { 'it' : 'it' } ,
170+ basePath : '/' ,
171+ } ) ;
172+
173+ appEngine = new AngularAppEngine ( ) ;
174+ } ) ;
175+
176+ describe ( 'handle' , ( ) => {
177+ it ( 'should return null for requests to unknown pages' , async ( ) => {
178+ const request = new Request ( 'https://example.com/unknown/page' ) ;
179+ const response = await appEngine . handle ( request ) ;
180+ expect ( response ) . toBeNull ( ) ;
181+ } ) ;
182+
183+ it ( 'should return a rendered page with correct locale' , async ( ) => {
184+ const request = new Request ( 'https://example.com/it/ssr' ) ;
185+ const response = await appEngine . handle ( request ) ;
186+ expect ( await response ?. text ( ) ) . toContain ( 'SSR works IT' ) ;
187+ } ) ;
188+
189+ it ( 'should correctly render the content when the URL ends with "index.html" with correct locale' , async ( ) => {
190+ const request = new Request ( 'https://example.com/it/ssr/index.html' ) ;
191+ const response = await appEngine . handle ( request ) ;
192+ expect ( await response ?. text ( ) ) . toContain ( 'SSR works IT' ) ;
193+ expect ( response ?. headers ?. get ( 'Content-Language' ) ) . toBe ( 'it' ) ;
194+ } ) ;
195+
196+ it ( 'should return a serve prerendered page with correct locale' , async ( ) => {
197+ const request = new Request ( 'https://example.com/it/ssg' ) ;
198+ const response = await appEngine . handle ( request ) ;
199+ expect ( await response ?. text ( ) ) . toContain ( 'SSG works IT' ) ;
200+ expect ( response ?. headers ?. get ( 'Content-Language' ) ) . toBe ( 'it' ) ;
201+ } ) ;
202+
203+ it ( 'should correctly serve the prerendered content when the URL ends with "index.html" with correct locale' , async ( ) => {
204+ const request = new Request ( 'https://example.com/it/ssg/index.html' ) ;
205+ const response = await appEngine . handle ( request ) ;
206+ expect ( await response ?. text ( ) ) . toContain ( 'SSG works IT' ) ;
207+ } ) ;
208+
209+ it ( 'should return null for requests to unknown pages in a locale' , async ( ) => {
210+ const request = new Request ( 'https://example.com/it/unknown/page' ) ;
211+ const response = await appEngine . handle ( request ) ;
212+ expect ( response ) . toBeNull ( ) ;
213+ } ) ;
214+
215+ it ( 'should return null for requests to file-like resources in a locale' , async ( ) => {
216+ const request = new Request ( 'https://example.com/it/logo.png' ) ;
217+ const response = await appEngine . handle ( request ) ;
218+ expect ( response ) . toBeNull ( ) ;
219+ } ) ;
220+ } ) ;
221+ } ) ;
222+
163223 describe ( 'Non-localized app' , ( ) => {
164224 beforeAll ( ( ) => {
165225 @Component ( {
0 commit comments