mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-25 23:11:31 +00:00
dd6c8e5147
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
49 lines
1.2 KiB
TypeScript
49 lines
1.2 KiB
TypeScript
import { git, mocked } from '../../../../test/util';
|
|
import type { CommitFilesConfig } from '../../../util/git/types';
|
|
import { GithubScm } from './scm';
|
|
import * as _github from '.';
|
|
|
|
jest.mock('.');
|
|
const github = mocked(_github);
|
|
|
|
describe('modules/platform/github/scm', () => {
|
|
beforeEach(() => {
|
|
jest.spyOn(git, 'commitFiles').mockResolvedValue('sha');
|
|
});
|
|
|
|
const githubScm = new GithubScm();
|
|
|
|
const commitObj = {
|
|
baseBranch: 'main',
|
|
branchName: 'branch',
|
|
files: [],
|
|
message: 'msg',
|
|
} satisfies CommitFilesConfig;
|
|
|
|
it('platformCommit = false => delegate to git', async () => {
|
|
await githubScm.commitAndPush({
|
|
...commitObj,
|
|
platformCommit: false,
|
|
});
|
|
|
|
expect(git.commitFiles).toHaveBeenCalledWith({
|
|
...commitObj,
|
|
platformCommit: false,
|
|
});
|
|
expect(github.commitFiles).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it('platformCommit = true => delegate to github', async () => {
|
|
await githubScm.commitAndPush({
|
|
...commitObj,
|
|
platformCommit: true,
|
|
});
|
|
|
|
expect(git.commitFiles).not.toHaveBeenCalled();
|
|
expect(github.commitFiles).toHaveBeenCalledWith({
|
|
...commitObj,
|
|
platformCommit: true,
|
|
});
|
|
});
|
|
});
|