-
Notifications
You must be signed in to change notification settings - Fork 279
/
Copy pathmake-env.test.js
35 lines (26 loc) · 936 Bytes
/
make-env.test.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
const os = require('os');
const path = require('path');
const { execFileSync } = require('child_process');
const { readFileSync } = require('fs');
const envFile = path.join(os.tmpdir(), 'tmpEnv');
test('Create & verify', () => {
const execFile = path.resolve(path.join(__dirname, '..', 'make-env.js'));
execFileSync('node', [execFile, envFile]);
const envContents = readFileSync(envFile).toString();
const lines = envContents.split(/\r?\n/);
const envObj = {};
lines.forEach(line => {
// Skip empty lines
if (!line) {
return;
}
const [key, val] = line.trim().split('=');
expect(key.trim()).toBeDefined();
expect(val.trim()).toBeDefined();
envObj[key] = val;
});
const keys = Object.keys(envObj);
expect(keys).toContain('REACT_APP_HEADLAMP_VERSION');
expect(keys).toContain('REACT_APP_HEADLAMP_GIT_VERSION');
expect(keys).toContain('REACT_APP_HEADLAMP_PRODUCT_NAME');
});