2021-08-18 05:46:56 +00:00
|
|
|
import { RenovateConfig, getConfig, git } from '../../../../test/util';
|
2021-05-28 10:36:53 +00:00
|
|
|
import { initialize } from '../../../util/cache/repository';
|
2020-03-05 20:57:24 +00:00
|
|
|
import { detectSemanticCommits } from './semantic';
|
2019-12-17 05:56:42 +00:00
|
|
|
|
2020-07-04 16:15:29 +00:00
|
|
|
jest.mock('../../../util/git');
|
|
|
|
|
2019-12-17 05:56:42 +00:00
|
|
|
let config: RenovateConfig;
|
2017-11-05 04:45:49 +00:00
|
|
|
beforeEach(() => {
|
|
|
|
jest.resetAllMocks();
|
2019-12-17 05:56:42 +00:00
|
|
|
config = getConfig();
|
2017-11-05 04:45:49 +00:00
|
|
|
config.errors = [];
|
|
|
|
config.warnings = [];
|
|
|
|
});
|
|
|
|
|
2021-08-18 05:46:56 +00:00
|
|
|
describe('workers/repository/init/semantic', () => {
|
2017-11-05 04:45:49 +00:00
|
|
|
describe('detectSemanticCommits()', () => {
|
2021-05-28 10:36:53 +00:00
|
|
|
beforeEach(async () => {
|
|
|
|
await initialize({});
|
|
|
|
});
|
2017-11-05 04:45:49 +00:00
|
|
|
it('detects false if unknown', async () => {
|
|
|
|
config.semanticCommits = null;
|
2021-05-28 10:36:53 +00:00
|
|
|
git.getCommitMessages.mockResolvedValueOnce(['foo', 'bar']);
|
|
|
|
git.getCommitMessages.mockResolvedValueOnce([
|
|
|
|
'fix: foo',
|
|
|
|
'refactor: bar',
|
|
|
|
]);
|
2020-09-01 08:44:52 +00:00
|
|
|
const res = await detectSemanticCommits();
|
2020-09-11 11:15:04 +00:00
|
|
|
expect(res).toBe('disabled');
|
2021-05-28 10:36:53 +00:00
|
|
|
const res2 = await detectSemanticCommits();
|
|
|
|
expect(res2).toBe('disabled');
|
2017-11-05 04:45:49 +00:00
|
|
|
});
|
|
|
|
it('detects true if known', async () => {
|
|
|
|
config.semanticCommits = null;
|
2020-07-04 16:15:29 +00:00
|
|
|
git.getCommitMessages.mockResolvedValue(['fix: foo', 'refactor: bar']);
|
2020-09-01 08:44:52 +00:00
|
|
|
const res = await detectSemanticCommits();
|
2020-09-11 11:15:04 +00:00
|
|
|
expect(res).toBe('enabled');
|
2017-11-05 04:45:49 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|