-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
file.spec.ts
63 lines (62 loc) · 1.9 KB
/
file.spec.ts
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
import fs from 'fs';
import upath from 'upath';
import customConfig from './config/__fixtures__/file';
import * as file from './file';
describe('config/file', () => {
describe('.getConfig()', () => {
it('returns empty env', () => {
expect(file.getConfig({ RENOVATE_CONFIG_FILE: 'dummylocation' })).toEqual(
{}
);
});
it('parses custom config file', () => {
const configFile = upath.resolve(
__dirname,
'./config/__fixtures__/file.js'
);
expect(file.getConfig({ RENOVATE_CONFIG_FILE: configFile })).toEqual(
customConfig
);
});
it('migrates', () => {
const configFile = upath.resolve(
__dirname,
'./config/__fixtures__/file2.js'
);
const res = file.getConfig({ RENOVATE_CONFIG_FILE: configFile });
expect(res).toMatchSnapshot();
expect(res.rangeStrategy).toEqual('bump');
});
it('informs user when error in parsing config.js', () => {
const configFile = upath.resolve(
__dirname,
'./config/__fixtures__/file3.ts'
);
const fileContent = `module.exports = {
"platform": "github",
"token":"abcdef",
"logFileLevel": "warn",
"onboarding": false,
"gitAuthor": "Renovate Bot <renovate@whitesourcesoftware.com>"
"onboardingConfig": {
"extends": ["config:base"],
},
"repositories": [ "test/test" ],
};`;
fs.writeFileSync(configFile, fileContent, { encoding: 'utf8' });
expect(
file.getConfig({ RENOVATE_CONFIG_FILE: configFile })
).toStrictEqual({});
fs.unlinkSync(configFile);
});
});
it('handles when invalid file location is provided', () => {
const configFile = upath.resolve(
__dirname,
'./config/__fixtures__/file4.ts'
);
expect(file.getConfig({ RENOVATE_CONFIG_FILE: configFile })).toStrictEqual(
{}
);
});
});