Skip to content

Commit

Permalink
Stub get latest ref
Browse files Browse the repository at this point in the history
  • Loading branch information
flurdy committed Jun 19, 2024
1 parent 7a0726d commit 09b38cd
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/api/github/controllers/commits.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,20 @@ const patchRefsController = {
}
}

export { repoCommitsController, postCommitsController, patchRefsController }
const getRefsController = {
handler: async (request, h) => {
const ref = {
object: {
sha: 'aa218f56b14c9653891f9e74264a383fa43fefbd'
}
}
return h.response(ref).code(200)
}
}

export {
getRefsController,
repoCommitsController,
postCommitsController,
patchRefsController
}
20 changes: 20 additions & 0 deletions src/api/github/controllers/commits.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { getRefsController } from '~/src/api/github/controllers/commits'

describe('Github Commits API', () => {
let mockViewHandler
describe('getRefsController', () => {
mockViewHandler = {
response: jest.fn().mockReturnThis(),
code: jest.fn().mockReturnThis()
}
it('should return the latest ref', async () => {
await getRefsController.handler(null, mockViewHandler)
expect(mockViewHandler.response).toHaveBeenCalledWith({
object: {
sha: 'aa218f56b14c9653891f9e74264a383fa43fefbd'
}
})
expect(mockViewHandler.code).toHaveBeenCalledWith(200)
})
})
})
6 changes: 6 additions & 0 deletions src/api/github/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { updateRepo } from '~/src/api/github/controllers/update-repo'
import { getRepoController } from '~/src/api/github/controllers/get-repo'
import { gitTreeController } from '~/src/api/github/controllers/gitTree'
import {
getRefsController,
patchRefsController,
postCommitsController,
repoCommitsController
Expand Down Expand Up @@ -52,6 +53,11 @@ const githubStub = {
path: '/graphql',
...graphqlController
},
{
method: 'GET',
path: '/repos/{org}/{repo}/git/refs/{path}',
...getRefsController
},
{
method: 'PATCH',
path: '/repos/{org}/{repo}/git/refs/{path}',
Expand Down

0 comments on commit 09b38cd

Please sign in to comment.