-
Notifications
You must be signed in to change notification settings - Fork 188
Expand file tree
/
Copy pathexplore-ram-bundle.test.ts
More file actions
77 lines (67 loc) · 2.46 KB
/
explore-ram-bundle.test.ts
File metadata and controls
77 lines (67 loc) · 2.46 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import path from 'path';
import fs from 'fs';
import { installDeps } from '../../utils/common';
import { bundleForPlatform, cleanup } from '../../utils/bundle';
import { runProcessSync } from '../../utils/runProcess';
const BIN_PATH = path.resolve(
__dirname,
'../../../packages/haul-explore/bin/haul-explore.js'
);
const PROJECT_FIXTURE = path.join(
__dirname,
'../../../fixtures',
'react_native_with_haul_0_60x'
);
describe('test exploring ram bundle', () => {
beforeAll(() => installDeps(PROJECT_FIXTURE));
beforeEach(() => cleanup(PROJECT_FIXTURE));
afterAll(() => cleanup(PROJECT_FIXTURE));
it('should return correct results for ram android bundle', () => {
const RESULT_PATH = path.join(PROJECT_FIXTURE, 'dist/output_android.json');
const bundlePath = bundleForPlatform(PROJECT_FIXTURE, 'android', {
ramBundle: true,
dev: false,
});
const unbundleFilePath = path.join(
path.dirname(bundlePath),
'js-modules/UNBUNDLE'
);
const result = runProcessSync(PROJECT_FIXTURE, [
BIN_PATH,
unbundleFilePath,
bundlePath + '.map',
`--json`,
RESULT_PATH,
]);
expect(fs.existsSync(RESULT_PATH)).toBeTruthy();
expect(result.stderr.length).toBe(0);
const output = fs.readFileSync(RESULT_PATH);
const resultJSON = JSON.parse(output.toString());
const bundleInformation = resultJSON.results[0];
expect(bundleInformation.totalBytes).toBeGreaterThan(0);
expect(Object.keys(bundleInformation.files).length).toBeGreaterThan(0);
expect(bundleInformation.bundleName).toEqual(path.basename(bundlePath));
});
it('should return correct results for ram ios bundle', () => {
const RESULT_PATH = path.join(PROJECT_FIXTURE, 'dist/output_ios.json');
const bundlePath = bundleForPlatform(PROJECT_FIXTURE, 'ios', {
ramBundle: true,
dev: false,
});
const result = runProcessSync(PROJECT_FIXTURE, [
BIN_PATH,
bundlePath,
bundlePath + '.map',
`--json`,
RESULT_PATH,
]);
expect(result.stderr.length).toBe(0);
expect(fs.existsSync(RESULT_PATH)).toBeTruthy();
const output = fs.readFileSync(RESULT_PATH);
const resultJSON = JSON.parse(output.toString());
const bundleInformation = resultJSON.results[0];
expect(bundleInformation.totalBytes).toBeGreaterThan(0);
expect(Object.keys(bundleInformation.files).length).toBeGreaterThan(0);
expect(bundleInformation.bundleName).toEqual(path.basename(bundlePath));
});
});