@@ -28,7 +28,7 @@ describe('augment-index-html', () => {
28
28
tags . stripIndents `${ html } ` . replace ( / ( > \s + ) / g, '>' ) ;
29
29
30
30
it ( 'can generate index.html' , async ( ) => {
31
- const source = augmentIndexHtml ( {
31
+ const { content } = await augmentIndexHtml ( {
32
32
...indexGeneratorOptions ,
33
33
files : [
34
34
{ file : 'styles.css' , extension : '.css' , name : 'styles' } ,
@@ -39,8 +39,7 @@ describe('augment-index-html', () => {
39
39
] ,
40
40
} ) ;
41
41
42
- const html = await source ;
43
- expect ( html ) . toEqual ( oneLineHtml `
42
+ expect ( content ) . toEqual ( oneLineHtml `
44
43
<html>
45
44
<head><base href="/">
46
45
<link rel="stylesheet" href="styles.css">
@@ -55,14 +54,13 @@ describe('augment-index-html', () => {
55
54
} ) ;
56
55
57
56
it ( 'should replace base href value' , async ( ) => {
58
- const source = augmentIndexHtml ( {
57
+ const { content } = await augmentIndexHtml ( {
59
58
...indexGeneratorOptions ,
60
59
html : '<html><head><base href="/"></head><body></body></html>' ,
61
60
baseHref : '/Apps/' ,
62
61
} ) ;
63
62
64
- const html = await source ;
65
- expect ( html ) . toEqual ( oneLineHtml `
63
+ expect ( content ) . toEqual ( oneLineHtml `
66
64
<html>
67
65
<head><base href="/Apps/">
68
66
</head>
@@ -72,15 +70,51 @@ describe('augment-index-html', () => {
72
70
` ) ;
73
71
} ) ;
74
72
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 ( {
77
75
...indexGeneratorOptions ,
78
76
lang : 'fr' ,
79
77
} ) ;
80
78
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">
84
118
<head>
85
119
<base href="/">
86
120
</head>
@@ -91,7 +125,7 @@ describe('augment-index-html', () => {
91
125
} ) ;
92
126
93
127
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 ( {
95
129
...indexGeneratorOptions ,
96
130
html : `<app-root></app-root>` ,
97
131
files : [
@@ -103,8 +137,7 @@ describe('augment-index-html', () => {
103
137
] ,
104
138
} ) ;
105
139
106
- const html = await source ;
107
- expect ( html ) . toEqual ( oneLineHtml `
140
+ expect ( content ) . toEqual ( oneLineHtml `
108
141
<link rel="stylesheet" href="styles.css">
109
142
<script src="runtime.js" type="module"></script>
110
143
<script src="polyfills.js" type="module"></script>
0 commit comments