renovate/lib/workers/repository/init/semantic.spec.ts
2020-09-11 13:15:04 +02:00

29 lines
908 B
TypeScript

import { RenovateConfig, getConfig, git } from '../../../../test/util';
import { detectSemanticCommits } from './semantic';
jest.mock('../../../util/git');
let config: RenovateConfig;
beforeEach(() => {
jest.resetAllMocks();
config = getConfig();
config.errors = [];
config.warnings = [];
});
describe('workers/repository/init/semantic', () => {
describe('detectSemanticCommits()', () => {
it('detects false if unknown', async () => {
config.semanticCommits = null;
git.getCommitMessages.mockResolvedValue(['foo', 'bar']);
const res = await detectSemanticCommits();
expect(res).toBe('disabled');
});
it('detects true if known', async () => {
config.semanticCommits = null;
git.getCommitMessages.mockResolvedValue(['fix: foo', 'refactor: bar']);
const res = await detectSemanticCommits();
expect(res).toBe('enabled');
});
});
});