Skip to content

Commit

Permalink
fix: getRepoCommits() test
Browse files Browse the repository at this point in the history
  • Loading branch information
adelkahomolova committed Nov 20, 2019
1 parent ccb1d70 commit 7ff57d6
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/services/git/GitHubService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import { GitHubNock } from '../../../test/helpers/gitHubNock';
import { getRepoCommitsResponse } from './__MOCKS__/gitHubServiceMockFolder/getRepoCommitsResponse.mock';
import { File } from './model';
import { GitHubPullRequestState } from './IGitHubService';
import util from 'util';
import { getRepoCommitsServiceResponse } from './__MOCKS__/gitHubServiceMockFolder/getRepoCommitsServiceResponse.mock';

describe('GitHub Service', () => {
let service: GitHubService;
Expand Down Expand Up @@ -105,12 +107,11 @@ describe('GitHub Service', () => {
expect(response).toMatchObject(getPullsReviewsServiceResponse);
});

it.only('returns commits in own interface', async () => {
//new GitHubNock('1', 'octocat', 1, 'Hello-World').getCommits().reply(200, getRepoCommitsResponse);
it('returns commits in own interface', async () => {
new GitHubNock('1', 'octocat', 1, 'Hello-World').getCommits().reply(200, getRepoCommitsResponse);
const response = await service.getRepoCommits('octocat', 'Hello-World');
console.log(response);

expect(response).toMatchObject(getRepoCommitsResponse);
expect(response).toMatchObject(getRepoCommitsServiceResponse);
});

it('returns commits in own interface', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { Paginated } from '../../../../inspectors/common/Paginated';
import { Commit } from '../../model';

export const getRepoCommitsServiceResponse: Paginated<Commit> = {
items: [
{
sha: '7fd1a60b01f91b314f59955a4e4d4e80d8edf11d',
url: 'https://api.github.com/repos/octocat/Hello-World/commits/7fd1a60b01f91b314f59955a4e4d4e80d8edf11d',
message: 'Merge pull request #6 from Spaceghost/patch-1\n' + '\n' + 'New line at end of file.',
author: {
name: 'The Octocat',
email: 'octocat@nowhere.com',
date: '2012-03-06T23:06:50Z',
},
tree: {
sha: 'b4eecafa9be2f2006ce1b709d6857b07069b4608',
url: 'https://api.github.com/repos/octocat/Hello-World/git/trees/b4eecafa9be2f2006ce1b709d6857b07069b4608',
},
verified: false,
},
{
sha: '762941318ee16e59dabbacb1b4049eec22f0d303',
url: 'https://api.github.com/repos/octocat/Hello-World/commits/762941318ee16e59dabbacb1b4049eec22f0d303',
message: 'New line at end of file. --Signed off by Spaceghost',
author: {
name: 'Johnneylee Jack Rollins',
email: 'johnneylee.rollins@gmail.com',
date: '2011-09-14T04:42:41Z',
},
tree: {
sha: 'b4eecafa9be2f2006ce1b709d6857b07069b4608',
url: 'https://api.github.com/repos/octocat/Hello-World/git/trees/b4eecafa9be2f2006ce1b709d6857b07069b4608',
},
verified: false,
},
{
sha: '553c2077f0edc3d5dc5d17262f6aa498e69d6f8e',
url: 'https://api.github.com/repos/octocat/Hello-World/commits/553c2077f0edc3d5dc5d17262f6aa498e69d6f8e',
message: 'first commit',
author: {
name: 'cameronmcefee',
email: 'cameron@github.com',
date: '2011-01-26T19:06:08Z',
},
tree: {
sha: 'fcf4a9bba6857422971d67147517eb5edfdbf48d',
url: 'https://api.github.com/repos/octocat/Hello-World/git/trees/fcf4a9bba6857422971d67147517eb5edfdbf48d',
},
verified: false,
},
],
totalCount: 3,
hasNextPage: false,
hasPreviousPage: false,
page: 1,
perPage: 3,
};

0 comments on commit 7ff57d6

Please sign in to comment.