2020-05-01 16:03:48 +00:00
|
|
|
import { defaultConfig, partial, platform } from '../../../test/util';
|
2020-03-05 20:57:24 +00:00
|
|
|
import { BranchConfig } from '../common';
|
2020-05-01 16:03:48 +00:00
|
|
|
import { commitFilesToBranch } from './commit';
|
2019-07-17 08:14:56 +00:00
|
|
|
|
2017-08-26 14:10:18 +00:00
|
|
|
describe('workers/branch/automerge', () => {
|
|
|
|
describe('commitFilesToBranch', () => {
|
2020-03-02 11:06:16 +00:00
|
|
|
let config: BranchConfig;
|
2017-08-26 14:10:18 +00:00
|
|
|
beforeEach(() => {
|
2020-03-02 11:06:16 +00:00
|
|
|
config = partial<BranchConfig>({
|
2017-08-26 14:10:18 +00:00
|
|
|
...defaultConfig,
|
|
|
|
branchName: 'renovate/some-branch',
|
|
|
|
commitMessage: 'some commit message',
|
|
|
|
semanticCommits: false,
|
2017-11-24 06:14:58 +00:00
|
|
|
semanticCommitType: 'a',
|
|
|
|
semanticCommitScope: 'b',
|
2017-08-26 14:10:18 +00:00
|
|
|
updatedPackageFiles: [],
|
2019-02-08 13:31:30 +00:00
|
|
|
updatedArtifacts: [],
|
2020-03-02 11:06:16 +00:00
|
|
|
});
|
2017-11-07 10:46:10 +00:00
|
|
|
jest.resetAllMocks();
|
2020-05-14 12:13:08 +00:00
|
|
|
platform.commitFiles.mockResolvedValueOnce('abc123');
|
2017-08-26 14:10:18 +00:00
|
|
|
});
|
|
|
|
it('handles empty files', async () => {
|
|
|
|
await commitFilesToBranch(config);
|
2020-05-14 12:13:08 +00:00
|
|
|
expect(platform.commitFiles).toHaveBeenCalledTimes(0);
|
2017-08-26 14:10:18 +00:00
|
|
|
});
|
|
|
|
it('commits files', async () => {
|
|
|
|
config.updatedPackageFiles.push({
|
|
|
|
name: 'package.json',
|
|
|
|
contents: 'some contents',
|
|
|
|
});
|
|
|
|
await commitFilesToBranch(config);
|
2020-05-14 12:13:08 +00:00
|
|
|
expect(platform.commitFiles).toHaveBeenCalledTimes(1);
|
|
|
|
expect(platform.commitFiles.mock.calls).toMatchSnapshot();
|
2017-08-26 14:10:18 +00:00
|
|
|
});
|
2018-10-26 07:48:49 +00:00
|
|
|
it('dry runs', async () => {
|
|
|
|
config.dryRun = true;
|
|
|
|
config.updatedPackageFiles.push({
|
|
|
|
name: 'package.json',
|
|
|
|
contents: 'some contents',
|
|
|
|
});
|
|
|
|
await commitFilesToBranch(config);
|
2020-05-14 12:13:08 +00:00
|
|
|
expect(platform.commitFiles).toHaveBeenCalledTimes(0);
|
2018-10-26 07:48:49 +00:00
|
|
|
});
|
2017-08-26 14:10:18 +00:00
|
|
|
});
|
|
|
|
});
|