2020-03-05 20:57:24 +00:00
|
|
|
import * as massage from './massage';
|
2021-04-20 08:52:57 +00:00
|
|
|
import type { RenovateConfig } from './types';
|
2017-08-15 11:26:05 +00:00
|
|
|
|
2021-08-18 05:46:56 +00:00
|
|
|
describe('config/massage', () => {
|
2017-08-15 11:26:05 +00:00
|
|
|
describe('massageConfig', () => {
|
|
|
|
it('returns empty', () => {
|
2019-08-23 13:46:31 +00:00
|
|
|
const config: RenovateConfig = {};
|
2017-08-15 11:26:05 +00:00
|
|
|
const res = massage.massageConfig(config);
|
2021-08-09 08:21:51 +00:00
|
|
|
expect(res).toEqual({});
|
2017-08-15 11:26:05 +00:00
|
|
|
});
|
|
|
|
it('massages strings to array', () => {
|
2019-08-23 13:46:31 +00:00
|
|
|
const config: RenovateConfig = {
|
2020-01-06 08:16:15 +00:00
|
|
|
schedule: 'before 5am' as never,
|
2017-08-15 11:26:05 +00:00
|
|
|
};
|
|
|
|
const res = massage.massageConfig(config);
|
|
|
|
expect(Array.isArray(res.schedule)).toBe(true);
|
|
|
|
});
|
2017-08-29 07:25:44 +00:00
|
|
|
it('massages npmToken', () => {
|
2019-08-23 13:46:31 +00:00
|
|
|
const config: RenovateConfig = {
|
2017-08-29 07:25:44 +00:00
|
|
|
npmToken: 'some-token',
|
|
|
|
};
|
2021-08-09 08:21:51 +00:00
|
|
|
expect(massage.massageConfig(config)).toEqual({
|
|
|
|
npmrc: '//registry.npmjs.org/:_authToken=some-token\n',
|
|
|
|
});
|
2017-08-29 07:25:44 +00:00
|
|
|
});
|
2021-01-29 10:43:42 +00:00
|
|
|
it('massages packageRules matchUpdateTypes', () => {
|
2019-08-23 13:46:31 +00:00
|
|
|
const config: RenovateConfig = {
|
2018-11-13 08:29:53 +00:00
|
|
|
packageRules: [
|
|
|
|
{
|
2021-01-29 10:43:42 +00:00
|
|
|
matchPackageNames: ['foo'],
|
2021-05-15 12:44:47 +00:00
|
|
|
separateMajorMinor: false,
|
2018-11-13 08:29:53 +00:00
|
|
|
minor: {
|
|
|
|
semanticCommitType: 'feat',
|
|
|
|
},
|
|
|
|
patch: {
|
|
|
|
semanticCommitType: 'fix',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
const res = massage.massageConfig(config);
|
|
|
|
expect(res).toMatchSnapshot();
|
|
|
|
expect(res.packageRules).toHaveLength(3);
|
|
|
|
});
|
2017-08-15 11:26:05 +00:00
|
|
|
});
|
|
|
|
});
|