@@ -222,11 +222,79 @@ describe('htmlEntrypoint', function() {
222222 it ( 'extracts configs from meta' , function ( ) {
223223 let tmpobj = tmp . dirSync ( ) ;
224224 let tmpLocation = tmpobj . name ;
225+ let configObj = {
226+ 'my-app' : {
227+ APP : {
228+ autoboot : false ,
229+ } ,
230+ configKey : 'someValue' ,
231+ } ,
232+ 'my-engine' : {
233+ APP : {
234+ autoboot : false ,
235+ } ,
236+ engineKey : 'engineValue' ,
237+ } ,
238+ } ;
239+ let metaTags = Object . entries ( configObj )
240+ . map (
241+ ( [ name , options ] ) =>
242+ `<meta name="${ name } /config/fastboot-environment" content="${ encodeURIComponent (
243+ JSON . stringify ( options )
244+ ) } "></meta>`
245+ )
246+ . join ( '\n' ) ;
247+
248+ let project = {
249+ 'index.html' : `
250+ <html>
251+ <head>
252+ ${ metaTags }
253+ </head>
254+ <body>
255+ <script src="/custom-root-url/bar.js"></script>
256+ </body>
257+ </html>
258+ ` ,
259+ } ;
260+
261+ fixturify . writeSync ( tmpLocation , project ) ;
262+ let { config } = htmlEntrypoint ( 'my-app' , tmpLocation , 'index.html' ) ;
263+ expect ( config ) . to . deep . equal ( configObj ) ;
264+ } ) ;
265+
266+ it ( 'support config fallback name "config/environement" when there is no fastboot-environement in HTML' , function ( ) {
267+ let tmpobj = tmp . dirSync ( ) ;
268+ let tmpLocation = tmpobj . name ;
269+ let configObj = {
270+ 'my-app' : {
271+ APP : {
272+ autoboot : false ,
273+ } ,
274+ configKey : 'someValue' ,
275+ } ,
276+ 'my-engine' : {
277+ APP : {
278+ autoboot : false ,
279+ } ,
280+ engineKey : 'engineValue' ,
281+ } ,
282+ } ;
283+ let metaTags = Object . entries ( configObj )
284+ . map (
285+ ( [ name , options ] ) =>
286+ `<meta name="${ name } /config/environment" content="${ encodeURIComponent (
287+ JSON . stringify ( options )
288+ ) } "></meta>`
289+ )
290+ . join ( '\n' ) ;
225291
226292 let project = {
227293 'index.html' : `
228294 <html>
229- <meta name="my-app/config/environment" content="%7B%22rootURL%22%3A%22%2Fcustom-root-url%2F%22%7D" >
295+ <head>
296+ ${ metaTags }
297+ </head>
230298 <body>
231299 <script src="/custom-root-url/bar.js"></script>
232300 </body>
@@ -235,20 +303,35 @@ describe('htmlEntrypoint', function() {
235303 } ;
236304
237305 fixturify . writeSync ( tmpLocation , project ) ;
306+
238307 let { config } = htmlEntrypoint ( 'my-app' , tmpLocation , 'index.html' ) ;
239- expect ( config ) . to . deep . equal ( {
240- 'my-app' : { APP : { autoboot : false } , rootURL : '/custom-root-url/' } ,
241- } ) ;
308+ expect ( config ) . to . deep . equal ( configObj ) ;
242309 } ) ;
243310
244311 it ( 'understands customized rootURL' , function ( ) {
245312 let tmpobj = tmp . dirSync ( ) ;
246313 let tmpLocation = tmpobj . name ;
314+ let config = {
315+ 'my-app' : {
316+ rootURL : '/custom-root-url/' ,
317+ } ,
318+ } ;
319+
320+ let metaTags = Object . entries ( config )
321+ . map (
322+ ( [ name , options ] ) =>
323+ `<meta name="${ name } /config/fastboot-environment" content="${ encodeURIComponent (
324+ JSON . stringify ( options )
325+ ) } "></meta>`
326+ )
327+ . join ( '\n' ) ;
247328
248329 let project = {
249330 'index.html' : `
250331 <html>
251- <meta name="my-app/config/environment" content="%7B%22rootURL%22%3A%22%2Fcustom-root-url%2F%22%7D" >
332+ <head>
333+ ${ metaTags }
334+ </head>
252335 <body>
253336 <fastboot-script src="foo.js"></fastboot-script>
254337 <script src="/custom-root-url/bar.js"></script>
0 commit comments