Skip to content

Commit

Permalink
update all dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjgrainger committed Dec 22, 2021
1 parent d10002e commit 40d33f9
Show file tree
Hide file tree
Showing 6 changed files with 8,837 additions and 13,028 deletions.
29 changes: 16 additions & 13 deletions __tests__/create-branch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ describe('Create a branch based on the input', () => {
let contextMock = JSON.parse(readFileSync('__tests__/context.json', 'utf8'));
let githubMock = jest.fn();
let octokitMock = {
git: {
createRef: jest.fn()
},
repos: {
getBranch: jest.fn()
rest: {
git: {
createRef: jest.fn()
},
repos: {
getBranch: jest.fn()
}
}

};

beforeEach(() => {
Expand All @@ -24,38 +27,38 @@ describe('Create a branch based on the input', () => {
});

it('gets a branch', async () => {
octokitMock.repos.getBranch.mockRejectedValue(new HttpError())
octokitMock.rest.repos.getBranch.mockRejectedValue(new HttpError())
process.env.GITHUB_REPOSITORY = 'peterjgrainger/test-action-changelog-reminder'
await createBranch(githubMock, context, branch)
expect(octokitMock.repos.getBranch).toHaveBeenCalledWith({
expect(octokitMock.rest.repos.getBranch).toHaveBeenCalledWith({
repo: 'test-action-changelog-reminder',
owner: 'peterjgrainger',
branch
})
});

it('Creates a new branch if not already there', async () => {
octokitMock.repos.getBranch.mockRejectedValue(new HttpError())
octokitMock.rest.repos.getBranch.mockRejectedValue(new HttpError())
await createBranch(githubMock, contextMock, branch)
expect(octokitMock.git.createRef).toHaveBeenCalledWith({
expect(octokitMock.rest.git.createRef).toHaveBeenCalledWith({
ref: 'refs/heads/release-v1',
sha: 'ebb4992dc72451c1c6c99e1cce9d741ec0b5b7d7'
})
});

it('Creates a new branch from a given commit SHA', async () => {
octokitMock.repos.getBranch.mockRejectedValue(new HttpError())
octokitMock.rest.repos.getBranch.mockRejectedValue(new HttpError())
await createBranch(githubMock, contextMock, branch, sha)
expect(octokitMock.git.createRef).toHaveBeenCalledWith({
expect(octokitMock.rest.git.createRef).toHaveBeenCalledWith({
ref: 'refs/heads/release-v1',
sha: 'ffac537e6cbbf934b08745a378932722df287a53'
})
})

it('Replaces refs/heads in branch name', async () => {
octokitMock.repos.getBranch.mockRejectedValue(new HttpError())
octokitMock.rest.repos.getBranch.mockRejectedValue(new HttpError())
await createBranch(githubMock, contextMock, `refs/heads/${branch}`)
expect(octokitMock.git.createRef).toHaveBeenCalledWith({
expect(octokitMock.rest.git.createRef).toHaveBeenCalledWith({
ref: 'refs/heads/release-v1',
sha: 'ebb4992dc72451c1c6c99e1cce9d741ec0b5b7d7'
})
Expand Down
Loading

0 comments on commit 40d33f9

Please sign in to comment.