Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tmeasday committed Sep 6, 2023
1 parent 29be461 commit 4bed9fe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion node-src/git/getCommitAndBranch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,19 @@ describe('getCommitAndBranch', () => {
expect(info).toMatchObject({ branch: 'master' });
});

it('throws when there is only one commit', async () => {
it('throws when there is only one commit, CI', async () => {
envCi.mockReturnValue({ isCi: true });
hasPreviousCommit.mockResolvedValue(false);
await expect(getCommitAndBranch({ log })).rejects.toThrow('Found only one commit');
});

it('does NOT throw when there is only one commit, non-CI', async () => {
envCi.mockReturnValue({ isCi: false });
hasPreviousCommit.mockResolvedValue(false);
const info = await getCommitAndBranch({ log });
expect(info).toMatchObject({});
});

describe('with branchName', () => {
it('uses provided branchName as branch', async () => {
const info = await getCommitAndBranch({ log }, { branchName: 'foobar' });
Expand Down
2 changes: 1 addition & 1 deletion node-src/git/getCommitAndBranch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface CommitInfo {
}

export default async function getCommitAndBranch(
{ log, options },
{ log },
{
branchName,
patchBaseRef,
Expand Down

0 comments on commit 4bed9fe

Please sign in to comment.