renovate/lib/workers/repository/init/semantic.spec.ts

30 lines
908 B
TypeScript
Raw Normal View History

import { RenovateConfig, getConfig, git } from '../../../../test/util';
2020-03-05 20:57:24 +00:00
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');
});
});
});