@@ -233,7 +233,7 @@ describe('Module - Core', () => {
233
233
Core . config ( JSON . stringify ( config ) ) ;
234
234
await Core . renderAsyncFragment ( 'test' ) ;
235
235
await Core . renderAsyncFragment ( 'test' ) ;
236
-
236
+
237
237
expect ( fetchStub . calledOnce ) . to . eq ( true ) ;
238
238
expect ( fetchStub . getCall ( 0 ) . lastArg . headers ) . to . haveOwnProperty ( "originalurl" ) ;
239
239
expect ( stubAsyncRenderResponse . calledOnce ) . to . eq ( true ) ;
@@ -288,7 +288,71 @@ describe('Module - Core', () => {
288
288
Core . config ( JSON . stringify ( config ) ) ;
289
289
await Core . renderAsyncFragment ( 'test' ) ;
290
290
await Core . renderAsyncFragment ( 'test' ) ;
291
-
291
+
292
+ expect ( fetchStub . calledOnce ) . to . eq ( true ) ;
293
+ expect ( fetchStub . getCall ( 0 ) . lastArg . headers ) . to . haveOwnProperty ( "originalurl" ) ;
294
+ expect ( stubAsyncRenderResponse . calledOnce ) . to . eq ( true ) ;
295
+ } ) ;
296
+
297
+ it ( 'should render async fragment withoutPathname' , async ( ) => {
298
+ const source = "source/" ;
299
+ const assets = [
300
+ {
301
+ name : 'bundle1' ,
302
+ dependent : [ 'vendor1' ] ,
303
+ preLoaded : false ,
304
+ link : 'bundle1.js' ,
305
+ fragment : 'test' ,
306
+ loadMethod : RESOURCE_LOADING_TYPE . ON_PAGE_RENDER ,
307
+ type : RESOURCE_TYPE . JS
308
+ }
309
+ ] as IPageLibAsset [ ] ;
310
+ const dependencies = [
311
+ {
312
+ name : 'vendor1' ,
313
+ link : 'vendor1.js' ,
314
+ preLoaded : false
315
+ }
316
+ ] as IPageLibDependency [ ] ;
317
+ const config = {
318
+ dependencies,
319
+ assets,
320
+ fragments : [ {
321
+ name : 'test' ,
322
+ attributes : {
323
+ if : "false" ,
324
+ withoutPathname : "true"
325
+ } ,
326
+ chunked : true ,
327
+ clientAsync : true ,
328
+ clientAsyncForce : undefined ,
329
+ onDemand : undefined ,
330
+ criticalCss : undefined ,
331
+ source,
332
+ asyncDecentralized : false
333
+ } ] ,
334
+ page : 'page' ,
335
+ peers : [ ]
336
+ } as IPageLibConfiguration ;
337
+
338
+ const fragmentContainer = global . window . document . createElement ( 'div' ) ;
339
+ fragmentContainer . setAttribute ( 'puzzle-fragment' , 'test' ) ;
340
+ global . window . document . body . appendChild ( fragmentContainer ) ;
341
+
342
+ const fetchStub = global . fetch as SinonStub ;
343
+ const stubAsyncRenderResponse = sandbox . stub ( Core as any , "asyncRenderResponse" ) . resolves ( ) ;
344
+
345
+ Core . config ( JSON . stringify ( config ) ) ;
346
+ await Core . renderAsyncFragment ( 'test' ) ;
347
+ await Core . renderAsyncFragment ( 'test' ) ;
348
+
349
+ const fragmentRequestUrl = `${ source } ?__renderMode=stream&if=false&withoutPathname=true` ;
350
+ expect ( fetchStub . calledWith ( fragmentRequestUrl , {
351
+ headers : {
352
+ originalurl : window . location . pathname
353
+ } ,
354
+ credentials : 'include'
355
+ } ) ) . to . eq ( true ) ;
292
356
expect ( fetchStub . calledOnce ) . to . eq ( true ) ;
293
357
expect ( fetchStub . getCall ( 0 ) . lastArg . headers ) . to . haveOwnProperty ( "originalurl" ) ;
294
358
expect ( stubAsyncRenderResponse . calledOnce ) . to . eq ( true ) ;
@@ -307,7 +371,7 @@ describe('Module - Core', () => {
307
371
308
372
Core . config ( JSON . stringify ( config ) ) ;
309
373
const result = Core . renderAsyncFragment ( 'test' ) ;
310
-
374
+
311
375
expect ( result ) . to . be . a ( 'promise' ) ;
312
376
} ) ;
313
377
@@ -353,7 +417,8 @@ describe('Module - Core', () => {
353
417
354
418
Core . config ( JSON . stringify ( config ) ) ;
355
419
const result = Core . renderAsyncFragment ( 'test' ) ;
356
-
420
+
357
421
expect ( result ) . to . be . a ( 'promise' ) ;
358
422
} ) ;
359
- } ) ;
423
+
424
+ } ) ;
0 commit comments