renovate/test/config/migration.spec.js
Rhys Arkins f8ec742b3b feat: Detect semantic commits every run (#609)
Now no need to detect at onboarding time. Also suggests removing setting in migration if it is already the same value.

Closes #528
2017-08-04 14:49:02 +02:00

75 lines
2.3 KiB
JavaScript

const configMigration = require('../../lib/config/migration.js');
const defaultConfig = require('../../lib/config/defaults').getConfig();
describe('config/migration', () => {
describe('migrateConfig(config, parentConfig)', () => {
it('it migrates config', () => {
const config = {
enabled: true,
maintainYarnLock: true,
schedule: 'after 5pm',
commitMessage: '{{semanticPrefix}}some commit message',
prTitle: '{{semanticPrefix}}some pr title',
semanticPrefix: 'fix(deps): ',
semanticCommits: false,
packages: [
{
packageName: 'angular',
packagePattern: 'ang',
enabled: false,
},
],
depTypes: [
'dependencies',
{
depType: 'optionalDependencies',
respectLatest: false,
},
],
};
const { isMigrated, migratedConfig } = configMigration.migrateConfig(
config,
defaultConfig
);
expect(isMigrated).toBe(true);
expect(migratedConfig.depTypes).not.toBeDefined();
expect(migratedConfig.optionalDependencies.respectLatest).toBe(false);
expect(migratedConfig).toMatchSnapshot();
});
it('it does not migrate config', () => {
const config = {
enabled: true,
semanticCommits: true,
separatePatchReleases: true,
};
const { isMigrated, migratedConfig } = configMigration.migrateConfig(
config
);
expect(isMigrated).toBe(false);
expect(migratedConfig).toMatchObject(config);
});
it('it migrates subconfig', () => {
const config = {
lockFileMaintenance: {
depTypes: [
'dependencies',
{
depType: 'optionalDependencies',
respectLatest: false,
},
],
},
};
const { isMigrated, migratedConfig } = configMigration.migrateConfig(
config,
defaultConfig
);
expect(isMigrated).toBe(true);
expect(migratedConfig).toMatchSnapshot();
expect(migratedConfig.lockFileMaintenance.depTypes).not.toBeDefined();
expect(
migratedConfig.lockFileMaintenance.optionalDependencies.respectLatest
).toBe(false);
});
});
});