-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathspec.js
53 lines (44 loc) · 1.21 KB
/
spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const chunkalyse = require('.');
const FIXTURES = [
'butter-toast',
'emoji-picker-react',
'react-dates',
];
describe('chunkalyse fixtures', () => {
it('Should not mutate the original object', () => {
const stats = require(`./fixtures/${FIXTURES[0]}.json`);
const before = JSON.stringify(stats);
chunkalyse(stats);
const after = JSON.stringify(stats);
expect(before).to.equal(after);
});
FIXTURES.forEach(
fixture => {
it(`[Degregation] Should match fixture stats with expected result for "${fixture}"`, () => {
expect(
chunkalyse(require(`./fixtures/${fixture}.json`)),
).to.deep.equal(
require(`./fixtures/${fixture}.chunkalised.json`),
);
});
},
);
FIXTURES.forEach(lib => {
describe(`Application size and modules size (${lib})`, () => {
const results = chunkalyse(require(`./fixtures/${lib}.json`));
Object.entries(results).forEach(
([ name, { size, modules } ]) =>
{
it(`Should reach full application size by modules sizes (${lib}/${name})`, () => {
const sum = Object.values(modules)
.map(({ size }) => size).reduce(
(sum, i) => sum + i,
0,
);
expect(sum).to.equal(size);
});
},
);
});
});
});