@@ -28,7 +28,7 @@ describe('augment-index-html', () => {
2828 tags . stripIndents `${ html } ` . replace ( / ( > \s + ) / g, '>' ) ;
2929
3030 it ( 'can generate index.html' , async ( ) => {
31- const source = augmentIndexHtml ( {
31+ const { content } = await augmentIndexHtml ( {
3232 ...indexGeneratorOptions ,
3333 files : [
3434 { file : 'styles.css' , extension : '.css' , name : 'styles' } ,
@@ -39,8 +39,7 @@ describe('augment-index-html', () => {
3939 ] ,
4040 } ) ;
4141
42- const html = await source ;
43- expect ( html ) . toEqual ( oneLineHtml `
42+ expect ( content ) . toEqual ( oneLineHtml `
4443 <html>
4544 <head><base href="/">
4645 <link rel="stylesheet" href="styles.css">
@@ -55,14 +54,13 @@ describe('augment-index-html', () => {
5554 } ) ;
5655
5756 it ( 'should replace base href value' , async ( ) => {
58- const source = augmentIndexHtml ( {
57+ const { content } = await augmentIndexHtml ( {
5958 ...indexGeneratorOptions ,
6059 html : '<html><head><base href="/"></head><body></body></html>' ,
6160 baseHref : '/Apps/' ,
6261 } ) ;
6362
64- const html = await source ;
65- expect ( html ) . toEqual ( oneLineHtml `
63+ expect ( content ) . toEqual ( oneLineHtml `
6664 <html>
6765 <head><base href="/Apps/">
6866 </head>
@@ -72,15 +70,51 @@ describe('augment-index-html', () => {
7270 ` ) ;
7371 } ) ;
7472
75- it ( 'should add lang attribute' , async ( ) => {
76- const source = augmentIndexHtml ( {
73+ it ( 'should add lang and dir LTR attribute for French (fr) ' , async ( ) => {
74+ const { content } = await augmentIndexHtml ( {
7775 ...indexGeneratorOptions ,
7876 lang : 'fr' ,
7977 } ) ;
8078
81- const html = await source ;
82- expect ( html ) . toEqual ( oneLineHtml `
83- <html lang="fr">
79+ expect ( content ) . toEqual ( oneLineHtml `
80+ <html lang="fr" dir="ltr">
81+ <head>
82+ <base href="/">
83+ </head>
84+ <body>
85+ </body>
86+ </html>
87+ ` ) ;
88+ } ) ;
89+
90+ it ( 'should add lang and dir RTL attribute for Pashto (ps)' , async ( ) => {
91+ const { content } = await augmentIndexHtml ( {
92+ ...indexGeneratorOptions ,
93+ lang : 'ps' ,
94+ } ) ;
95+
96+ expect ( content ) . toEqual ( oneLineHtml `
97+ <html lang="ps" dir="rtl">
98+ <head>
99+ <base href="/">
100+ </head>
101+ <body>
102+ </body>
103+ </html>
104+ ` ) ;
105+ } ) ;
106+
107+ it ( `should work when lang (locale) is not provided by '@angular/common'` , async ( ) => {
108+ const { content, warnings } = await augmentIndexHtml ( {
109+ ...indexGeneratorOptions ,
110+ lang : 'xx-XX' ,
111+ } ) ;
112+
113+ expect ( warnings ) . toEqual ( [
114+ `Locale data for 'xx-XX' cannot be found. 'dir' attribute will not be set for this locale.` ,
115+ ] ) ;
116+ expect ( content ) . toEqual ( oneLineHtml `
117+ <html lang="xx-XX">
84118 <head>
85119 <base href="/">
86120 </head>
@@ -91,7 +125,7 @@ describe('augment-index-html', () => {
91125 } ) ;
92126
93127 it ( `should add script and link tags even when body and head element doesn't exist` , async ( ) => {
94- const source = augmentIndexHtml ( {
128+ const { content } = await augmentIndexHtml ( {
95129 ...indexGeneratorOptions ,
96130 html : `<app-root></app-root>` ,
97131 files : [
@@ -103,8 +137,7 @@ describe('augment-index-html', () => {
103137 ] ,
104138 } ) ;
105139
106- const html = await source ;
107- expect ( html ) . toEqual ( oneLineHtml `
140+ expect ( content ) . toEqual ( oneLineHtml `
108141 <link rel="stylesheet" href="styles.css">
109142 <script src="runtime.js" type="module"></script>
110143 <script src="polyfills.js" type="module"></script>
0 commit comments