Skip to content

Commit f416c47

Browse files
committed
Add tests
1 parent 3d7745a commit f416c47

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

test/assetHelper.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,23 @@ describe('Module - Asset Helper', () => {
5151
expect(global.window.document.body.children.length).to.eq(1);
5252
});
5353

54+
it('should append link tag without promise', () => {
55+
// arrange
56+
const asset: IPageLibAsset = {
57+
name: faker.lorem.word(),
58+
loadMethod: RESOURCE_LOADING_TYPE.ON_FRAGMENT_RENDER,
59+
fragment: faker.lorem.word(),
60+
dependent: [],
61+
type: RESOURCE_TYPE.CSS,
62+
link: faker.lorem.word(),
63+
preLoaded: false
64+
};
65+
66+
// act
67+
const result = AssetHelper.loadCSS(asset);
68+
69+
// assert
70+
expect(global.window.document.head.children.length).to.eq(1);
71+
});
72+
5473
});

test/core.spec.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ describe('Module - Core', () => {
6464

6565
Core.onVariables(fragmentName, variableName, windowModel);
6666

67-
console.log(window[variableName]);
68-
6967
expect(window[variableName]).to.deep.eq(windowModel);
7068
});
7169

@@ -87,7 +85,7 @@ describe('Module - Core', () => {
8785
expect(global.window.document.body.innerHTML).to.eq(`<div id="${fragmentContainerId}">${fragmentContent}</div>`);
8886
});
8987

90-
it('should create true load queue for js assets', function () {
88+
it('should create true load queue for js and css assets', function () {
9189
const assets = [
9290
{
9391
name: 'bundle1',
@@ -97,6 +95,13 @@ describe('Module - Core', () => {
9795
fragment: 'test',
9896
loadMethod: RESOURCE_LOADING_TYPE.ON_PAGE_RENDER,
9997
type: RESOURCE_TYPE.JS
98+
},
99+
{
100+
name: 'css1',
101+
link: 'css1.js',
102+
fragment: 'test',
103+
loadMethod: RESOURCE_LOADING_TYPE.ON_PAGE_RENDER,
104+
type: RESOURCE_TYPE.CSS
100105
}
101106
] as IPageLibAsset[];
102107
const dependencies = [
@@ -131,6 +136,13 @@ describe('Module - Core', () => {
131136
loadMethod: 2,
132137
type: 1,
133138
defer: true
139+
},
140+
{
141+
name: 'css1',
142+
link: 'css1.js',
143+
fragment: 'test',
144+
loadMethod: 2,
145+
type: 0
134146
}
135147
]);
136148
});
@@ -203,6 +215,7 @@ describe('Module - Core', () => {
203215
clientAsync: true,
204216
clientAsyncForce: undefined,
205217
onDemand: undefined,
218+
criticalCss: undefined,
206219
source: undefined,
207220
asyncDecentralized: false
208221
}],
@@ -257,6 +270,7 @@ describe('Module - Core', () => {
257270
clientAsync: true,
258271
clientAsyncForce: true,
259272
onDemand: undefined,
273+
criticalCss: undefined,
260274
source: undefined,
261275
asyncDecentralized: false
262276
}],
@@ -328,6 +342,7 @@ describe('Module - Core', () => {
328342
clientAsync: true,
329343
clientAsyncForce: undefined,
330344
onDemand: undefined,
345+
criticalCss: undefined,
331346
source: undefined,
332347
asyncDecentralized: false,
333348
asyncLoaded: true

0 commit comments

Comments
 (0)