Files
renovate/lib/modules/platform/github/scm.spec.ts
T
Tom Vervoort c82b9afb36 refactor: strongly type commit SHAs (#25207)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2023-11-22 06:30:19 +00:00

49 lines
1.2 KiB
TypeScript

import { git, mocked } from '../../../../test/util';
import type { CommitFilesConfig, LongCommitSha } 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' as LongCommitSha);
});
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,
});
});
});