6
6
* found in the LICENSE file at https://angular.io/license
7
7
*/
8
8
9
- import { StatsCompilation } from 'webpack' ;
10
- import { Budget , Type } from '../builders/browser/schema' ;
11
- import { ThresholdSeverity , checkBudgets } from './bundle-calculator' ;
9
+ import { BudgetEntry , BudgetType , ThresholdSeverity , checkBudgets } from './bundle-calculator' ;
12
10
13
11
const KB = 1024 ;
14
12
15
13
describe ( 'bundle-calculator' , ( ) => {
16
14
describe ( 'checkBudgets()' , ( ) => {
17
15
it ( 'yields maximum budgets exceeded' , ( ) => {
18
- const budgets : Budget [ ] = [
16
+ const budgets : BudgetEntry [ ] = [
19
17
{
20
- type : Type . Any ,
18
+ type : BudgetType . Any ,
21
19
maximumError : '1kb' ,
22
20
} ,
23
21
] ;
@@ -33,7 +31,7 @@ describe('bundle-calculator', () => {
33
31
size : 0.5 * KB ,
34
32
} ,
35
33
] ,
36
- } as unknown as StatsCompilation ;
34
+ } ;
37
35
38
36
const failures = Array . from ( checkBudgets ( budgets , stats ) ) ;
39
37
@@ -46,9 +44,9 @@ describe('bundle-calculator', () => {
46
44
} ) ;
47
45
48
46
it ( 'yields minimum budgets exceeded' , ( ) => {
49
- const budgets : Budget [ ] = [
47
+ const budgets : BudgetEntry [ ] = [
50
48
{
51
- type : Type . Any ,
49
+ type : BudgetType . Any ,
52
50
minimumError : '1kb' ,
53
51
} ,
54
52
] ;
@@ -64,7 +62,7 @@ describe('bundle-calculator', () => {
64
62
size : 0.5 * KB ,
65
63
} ,
66
64
] ,
67
- } as unknown as StatsCompilation ;
65
+ } ;
68
66
69
67
const failures = Array . from ( checkBudgets ( budgets , stats ) ) ;
70
68
@@ -77,9 +75,9 @@ describe('bundle-calculator', () => {
77
75
} ) ;
78
76
79
77
it ( 'yields exceeded bundle budgets' , ( ) => {
80
- const budgets : Budget [ ] = [
78
+ const budgets : BudgetEntry [ ] = [
81
79
{
82
- type : Type . Bundle ,
80
+ type : BudgetType . Bundle ,
83
81
name : 'foo' ,
84
82
maximumError : '1kb' ,
85
83
} ,
@@ -102,7 +100,7 @@ describe('bundle-calculator', () => {
102
100
size : 0.75 * KB ,
103
101
} ,
104
102
] ,
105
- } as unknown as StatsCompilation ;
103
+ } ;
106
104
107
105
const failures = Array . from ( checkBudgets ( budgets , stats ) ) ;
108
106
@@ -115,9 +113,9 @@ describe('bundle-calculator', () => {
115
113
} ) ;
116
114
117
115
it ( 'yields exceeded initial budget' , ( ) => {
118
- const budgets : Budget [ ] = [
116
+ const budgets : BudgetEntry [ ] = [
119
117
{
120
- type : Type . Initial ,
118
+ type : BudgetType . Initial ,
121
119
maximumError : '1kb' ,
122
120
} ,
123
121
] ;
@@ -140,7 +138,7 @@ describe('bundle-calculator', () => {
140
138
size : 0.75 * KB ,
141
139
} ,
142
140
] ,
143
- } as unknown as StatsCompilation ;
141
+ } ;
144
142
145
143
const failures = Array . from ( checkBudgets ( budgets , stats ) ) ;
146
144
@@ -153,9 +151,9 @@ describe('bundle-calculator', () => {
153
151
} ) ;
154
152
155
153
it ( 'yields exceeded total scripts budget' , ( ) => {
156
- const budgets : Budget [ ] = [
154
+ const budgets : BudgetEntry [ ] = [
157
155
{
158
- type : Type . AllScript ,
156
+ type : BudgetType . AllScript ,
159
157
maximumError : '1kb' ,
160
158
} ,
161
159
] ;
@@ -182,7 +180,7 @@ describe('bundle-calculator', () => {
182
180
size : 1.5 * KB ,
183
181
} ,
184
182
] ,
185
- } as unknown as StatsCompilation ;
183
+ } ;
186
184
187
185
const failures = Array . from ( checkBudgets ( budgets , stats ) ) ;
188
186
@@ -195,9 +193,9 @@ describe('bundle-calculator', () => {
195
193
} ) ;
196
194
197
195
it ( 'yields exceeded total budget' , ( ) => {
198
- const budgets : Budget [ ] = [
196
+ const budgets : BudgetEntry [ ] = [
199
197
{
200
- type : Type . All ,
198
+ type : BudgetType . All ,
201
199
maximumError : '1kb' ,
202
200
} ,
203
201
] ;
@@ -220,7 +218,7 @@ describe('bundle-calculator', () => {
220
218
size : 0.75 * KB ,
221
219
} ,
222
220
] ,
223
- } as unknown as StatsCompilation ;
221
+ } ;
224
222
225
223
const failures = Array . from ( checkBudgets ( budgets , stats ) ) ;
226
224
@@ -233,9 +231,9 @@ describe('bundle-calculator', () => {
233
231
} ) ;
234
232
235
233
it ( 'skips component style budgets' , ( ) => {
236
- const budgets : Budget [ ] = [
234
+ const budgets : BudgetEntry [ ] = [
237
235
{
238
- type : Type . AnyComponentStyle ,
236
+ type : BudgetType . AnyComponentStyle ,
239
237
maximumError : '1kb' ,
240
238
} ,
241
239
] ;
@@ -258,17 +256,17 @@ describe('bundle-calculator', () => {
258
256
size : 0.5 * KB ,
259
257
} ,
260
258
] ,
261
- } as unknown as StatsCompilation ;
259
+ } ;
262
260
263
261
const failures = Array . from ( checkBudgets ( budgets , stats ) ) ;
264
262
265
263
expect ( failures . length ) . toBe ( 0 ) ;
266
264
} ) ;
267
265
268
266
it ( 'yields exceeded individual script budget' , ( ) => {
269
- const budgets : Budget [ ] = [
267
+ const budgets : BudgetEntry [ ] = [
270
268
{
271
- type : Type . AnyScript ,
269
+ type : BudgetType . AnyScript ,
272
270
maximumError : '1kb' ,
273
271
} ,
274
272
] ;
@@ -291,7 +289,7 @@ describe('bundle-calculator', () => {
291
289
size : 0.5 * KB ,
292
290
} ,
293
291
] ,
294
- } as unknown as StatsCompilation ;
292
+ } ;
295
293
296
294
const failures = Array . from ( checkBudgets ( budgets , stats ) ) ;
297
295
@@ -304,9 +302,9 @@ describe('bundle-calculator', () => {
304
302
} ) ;
305
303
306
304
it ( 'yields exceeded individual file budget' , ( ) => {
307
- const budgets : Budget [ ] = [
305
+ const budgets : BudgetEntry [ ] = [
308
306
{
309
- type : Type . Any ,
307
+ type : BudgetType . Any ,
310
308
maximumError : '1kb' ,
311
309
} ,
312
310
] ;
@@ -329,7 +327,7 @@ describe('bundle-calculator', () => {
329
327
size : 0.5 * KB ,
330
328
} ,
331
329
] ,
332
- } as unknown as StatsCompilation ;
330
+ } ;
333
331
334
332
const failures = Array . from ( checkBudgets ( budgets , stats ) ) ;
335
333
0 commit comments