mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-25 15:01:49 +00:00
80 lines
2.0 KiB
TypeScript
80 lines
2.0 KiB
TypeScript
import { git } from '~test/util.ts';
|
|
import type {
|
|
CommitFilesConfig,
|
|
LongCommitSha,
|
|
} from '../../../util/git/types.ts';
|
|
import * as _github from './index.ts';
|
|
import { GithubScm } from './scm.ts';
|
|
|
|
vi.mock('./index.ts');
|
|
const github = vi.mocked(_github);
|
|
|
|
describe('modules/platform/github/scm', () => {
|
|
beforeEach(() => {
|
|
git.commitFiles.mockResolvedValue('sha' as LongCommitSha);
|
|
});
|
|
|
|
const githubScm = new GithubScm();
|
|
|
|
const commitObj = {
|
|
baseBranch: 'main',
|
|
branchName: 'branch',
|
|
files: [],
|
|
message: 'msg',
|
|
} satisfies CommitFilesConfig;
|
|
|
|
it('platformCommit = disabled => delegate to git', async () => {
|
|
await githubScm.commitAndPush({
|
|
...commitObj,
|
|
platformCommit: 'disabled',
|
|
});
|
|
|
|
expect(git.commitFiles).toHaveBeenCalledExactlyOnceWith({
|
|
...commitObj,
|
|
platformCommit: 'disabled',
|
|
});
|
|
expect(github.commitFiles).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it('platformCommit = enabled => delegate to github', async () => {
|
|
await githubScm.commitAndPush({
|
|
...commitObj,
|
|
platformCommit: 'enabled',
|
|
});
|
|
|
|
expect(git.commitFiles).not.toHaveBeenCalled();
|
|
expect(github.commitFiles).toHaveBeenCalledExactlyOnceWith({
|
|
...commitObj,
|
|
platformCommit: 'enabled',
|
|
});
|
|
});
|
|
|
|
it('platformCommit = auto => delegate to git', async () => {
|
|
await githubScm.commitAndPush({
|
|
...commitObj,
|
|
platformCommit: 'auto',
|
|
});
|
|
|
|
expect(git.commitFiles).toHaveBeenCalledExactlyOnceWith({
|
|
...commitObj,
|
|
platformCommit: 'auto',
|
|
});
|
|
expect(github.commitFiles).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it('platformCommit = auto and is a github app => delegate to github', async () => {
|
|
github.isGHApp.mockReturnValueOnce(true);
|
|
|
|
await githubScm.commitAndPush({
|
|
...commitObj,
|
|
platformCommit: 'auto',
|
|
});
|
|
|
|
expect(git.commitFiles).not.toHaveBeenCalled();
|
|
expect(github.commitFiles).toHaveBeenCalledExactlyOnceWith({
|
|
...commitObj,
|
|
platformCommit: 'auto',
|
|
});
|
|
});
|
|
});
|