@@ -3,10 +3,14 @@ import {JSDOM} from "jsdom";
33import { PuzzleJs } from "../src/puzzle" ;
44import { Core } from "../src/core" ;
55import { createPageLibConfiguration } from "./mock" ;
6+ import sinon from "sinon" ;
7+ import { AssetHelper } from "../src/assetHelper" ;
68import * as faker from "faker" ;
79import { IPageLibAsset , IPageLibConfiguration , IPageLibDependency } from "../src/types" ;
810import { RESOURCE_LOADING_TYPE , RESOURCE_TYPE } from "../src/enums" ;
911
12+ const sandbox = sinon . createSandbox ( ) ;
13+
1014declare global {
1115 interface Window {
1216 [ key : string ] : any ;
@@ -25,6 +29,7 @@ declare var global: Global;
2529describe ( 'Module - Core' , ( ) => {
2630 beforeEach ( ( ) => {
2731 global . window = ( new JSDOM ( `` , { runScripts : "outside-only" } ) ) . window ;
32+ sandbox . verifyAndRestore ( ) ;
2833 } ) ;
2934
3035 afterEach ( ( ) => {
@@ -164,4 +169,46 @@ describe('Module - Core', () => {
164169 expect ( queue ) . to . deep . eq (
165170 [ ] ) ;
166171 } ) ;
172+
173+ it ( 'should create true load queue for js assets excluding conditional fragments' , function ( ) {
174+ const assets = [
175+ {
176+ name : 'bundle1' ,
177+ dependent : [ 'vendor1' ] ,
178+ preLoaded : false ,
179+ link : 'bundle1.js' ,
180+ fragment : 'test' ,
181+ loadMethod : RESOURCE_LOADING_TYPE . ON_PAGE_RENDER ,
182+ type : RESOURCE_TYPE . JS
183+ }
184+ ] as IPageLibAsset [ ] ;
185+ const dependencies = [
186+ {
187+ name : 'vendor1' ,
188+ link : 'vendor1.js' ,
189+ preLoaded : false
190+ }
191+ ] as IPageLibDependency [ ] ;
192+ const config = {
193+ dependencies,
194+ assets,
195+ fragments : [ {
196+ name : 'test' ,
197+ attributes : {
198+ if : "false"
199+ } ,
200+ chunked : true ,
201+ clientAsync : false ,
202+ source : undefined
203+ } ] ,
204+ page : 'page'
205+ } as IPageLibConfiguration ;
206+
207+ const mockLoadJsSeries = sandbox . mock ( AssetHelper ) ;
208+
209+ Core . config ( JSON . stringify ( config ) ) ;
210+ Core . pageLoaded ( ) ;
211+
212+ mockLoadJsSeries . expects ( "loadJsSeries" ) . calledWith ( [ ] ) ;
213+ } ) ;
167214} ) ;
0 commit comments