-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
82927c1
commit cf670c3
Showing
3 changed files
with
115 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
export const commitListMock = new Promise((resolve, reject) => resolve({ | ||
data: [{ | ||
sha: 'bd75cf8acc664414df895ed5d623c3426b167321', | ||
node_id: 'C_kwDOKy00BNoAKGJkNzVjZjhhY2M2NjQ0MTRkZjg5NWVkNWQ2MjNjMzQyNmIxNjczMjE', | ||
commit: { | ||
author: { | ||
name: 'Santiago Javier Rubio', | ||
email: '[email protected]', | ||
date: '2023-11-29T13:27:48Z' | ||
}, | ||
committer: { | ||
name: 'GitHub', | ||
email: '[email protected]', | ||
date: '2023-11-29T13:27:48Z' | ||
}, | ||
message: 'Merge pull request #2 from SantiagoJavierRubio/dev-client\n\nClient cleanup & setup', | ||
tree: { | ||
sha: 'f91a62c5a9498af36d8b66d1ab26d8d6c43482f7', | ||
url: 'https://api.github.com/repos/SantiagoJavierRubio/git-commit-history/git/trees/f91a62c5a9498af36d8b66d1ab26d8d6c43482f7' | ||
}, | ||
url: 'https://api.github.com/repos/SantiagoJavierRubio/git-commit-history/git/commits/bd75cf8acc664414df895ed5d623c3426b167321', | ||
comment_count: 0, | ||
verification: { | ||
verified: true, | ||
reason: 'valid', | ||
signature: '-----BEGIN PGP SIGNATURE-----\n\nwsBcBAABCAAQBQJlZzxUCRBK7hj4Ov3rIwAATzgIAHw91oJl2TzvR6UGl+mJvjlW\nApSrRmoNMdlYApdIitgWa6NzSMd/X4gkAdXtdmX8MlMemorpz3MO+BxAoirEb9oX\nflh3+y/gelIrDy72hlE2PZjyzcCAPxeF4APa1tu3cqeVlkAWlYsUv+mgpzlc/2s6\n9auj6xYIo13qunedVSV0Gby2qneQWf15xb4AaDxb8GTwHWi3U3Dgag7QhBSP4AgJ\nTePyjYKYs85x6ACtgW86e8o7K3Mpzg1ZFrCm61hbC77Mnj9h7F4HtZXIlzuHh4j0\ndngW2ecXDC/cJI+V2yFJUIO3o0RTEXdiyBX46scwVo3XqKlopkwvk91tcZE8bgs=\n=Fhc8\n-----END PGP SIGNATURE-----\n', | ||
payload: 'tree f91a62c5a9498af36d8b66d1ab26d8d6c43482f7\nparent 5336e9079a916c32f41e04523bd5b9b08de9e55d\nparent aee9d11a05bcda6f30ba202eda0d5532e699ea92\nauthor Santiago Javier Rubio <[email protected]> 1701264468 -0300\ncommitter GitHub <[email protected]> 1701264468 -0300\n\nMerge pull request #2 from SantiagoJavierRubio/dev-client\n\nClient cleanup & setup' | ||
} | ||
}, | ||
url: 'https://api.github.com/repos/SantiagoJavierRubio/git-commit-history/commits/bd75cf8acc664414df895ed5d623c3426b167321', | ||
html_url: 'https://github.com/SantiagoJavierRubio/git-commit-history/commit/bd75cf8acc664414df895ed5d623c3426b167321', | ||
comments_url: 'https://api.github.com/repos/SantiagoJavierRubio/git-commit-history/commits/bd75cf8acc664414df895ed5d623c3426b167321/comments', | ||
author: { | ||
login: 'SantiagoJavierRubio', | ||
id: 62577814, | ||
node_id: 'MDQ6VXNlcjYyNTc3ODE0', | ||
avatar_url: 'https://avatars.githubusercontent.com/u/62577814?v=4', | ||
gravatar_id: '', | ||
url: 'https://api.github.com/users/SantiagoJavierRubio', | ||
html_url: 'https://github.com/SantiagoJavierRubio', | ||
followers_url: 'https://api.github.com/users/SantiagoJavierRubio/followers', | ||
following_url: 'https://api.github.com/users/SantiagoJavierRubio/following{/other_user}', | ||
gists_url: 'https://api.github.com/users/SantiagoJavierRubio/gists{/gist_id}', | ||
starred_url: 'https://api.github.com/users/SantiagoJavierRubio/starred{/owner}{/repo}', | ||
subscriptions_url: 'https://api.github.com/users/SantiagoJavierRubio/subscriptions', | ||
organizations_url: 'https://api.github.com/users/SantiagoJavierRubio/orgs', | ||
repos_url: 'https://api.github.com/users/SantiagoJavierRubio/repos', | ||
events_url: 'https://api.github.com/users/SantiagoJavierRubio/events{/privacy}', | ||
received_events_url: 'https://api.github.com/users/SantiagoJavierRubio/received_events', | ||
type: 'User', | ||
site_admin: false | ||
}, | ||
committer: { | ||
login: 'web-flow', | ||
id: 19864447, | ||
node_id: 'MDQ6VXNlcjE5ODY0NDQ3', | ||
avatar_url: 'https://avatars.githubusercontent.com/u/19864447?v=4', | ||
gravatar_id: '', | ||
url: 'https://api.github.com/users/web-flow', | ||
html_url: 'https://github.com/web-flow', | ||
followers_url: 'https://api.github.com/users/web-flow/followers', | ||
following_url: 'https://api.github.com/users/web-flow/following{/other_user}', | ||
gists_url: 'https://api.github.com/users/web-flow/gists{/gist_id}', | ||
starred_url: 'https://api.github.com/users/web-flow/starred{/owner}{/repo}', | ||
subscriptions_url: 'https://api.github.com/users/web-flow/subscriptions', | ||
organizations_url: 'https://api.github.com/users/web-flow/orgs', | ||
repos_url: 'https://api.github.com/users/web-flow/repos', | ||
events_url: 'https://api.github.com/users/web-flow/events{/privacy}', | ||
received_events_url: 'https://api.github.com/users/web-flow/received_events', | ||
type: 'User', | ||
site_admin: false | ||
}, | ||
parents: [ | ||
{ | ||
sha: '5336e9079a916c32f41e04523bd5b9b08de9e55d', | ||
url: 'https://api.github.com/repos/SantiagoJavierRubio/git-commit-history/commits/5336e9079a916c32f41e04523bd5b9b08de9e55d', | ||
html_url: 'https://github.com/SantiagoJavierRubio/git-commit-history/commit/5336e9079a916c32f41e04523bd5b9b08de9e55d' | ||
}, | ||
{ | ||
sha: 'aee9d11a05bcda6f30ba202eda0d5532e699ea92', | ||
url: 'https://api.github.com/repos/SantiagoJavierRubio/git-commit-history/commits/aee9d11a05bcda6f30ba202eda0d5532e699ea92', | ||
html_url: 'https://github.com/SantiagoJavierRubio/git-commit-history/commit/aee9d11a05bcda6f30ba202eda0d5532e699ea92' | ||
} | ||
] | ||
}] | ||
}) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { CommitsController } from '../../src/commits/commits.controller' | ||
import { OctokitClient } from '../../src/octokit/octokitClient' | ||
import { ConfigService } from '@nestjs/config' | ||
import { CommitsService } from '../../src/commits/commits.service' | ||
import { commitListMock } from './__mocks__/commits.mocks' | ||
|
||
describe('Commits controller', () => { | ||
let octokit: OctokitClient | ||
let configService: ConfigService | ||
let commitsController: CommitsController | ||
let commitsService: CommitsService | ||
|
||
beforeEach(() => { | ||
configService = new ConfigService() | ||
octokit = new OctokitClient(configService) | ||
commitsService = new CommitsService(octokit, configService) | ||
commitsController = new CommitsController(commitsService) | ||
}) | ||
|
||
describe('getAll', () => { | ||
it('Should return array of commits', async () => { | ||
jest.spyOn(commitsService, 'getAllCommits').mockImplementation(() => commitListMock as ReturnType<typeof commitsService.getAllCommits>) | ||
expect((await commitsController.getAll())).toBe(await commitListMock) | ||
}) | ||
}) | ||
}) |