Skip to content

Commit

Permalink
fix: fix tests and use mockBitbucketPullRequestResponse()
Browse files Browse the repository at this point in the history
  • Loading branch information
adelkahomolova committed Dec 6, 2019
1 parent 905fd11 commit 1b6be4a
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/services/bitbucket/BitbucketService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,16 @@ import nock from 'nock';
import { BitbucketNock } from '../../../test/helpers/bitbucketNock';
import { ListGetterOptions } from '../../inspectors/common/ListGetterOptions';
import { PullRequestState } from '../../inspectors/ICollaborationInspector';
import { BitbucketPullRequestState, VCSService } from '../git/IVCSService';
import { VCSServicesUtils } from '../git/VCSServicesUtils';
import { getIssueCommentsResponse } from '../git/__MOCKS__/bitbucketServiceMockFolder/getIssueCommentsResponse';
import { getIssueResponse } from '../git/__MOCKS__/bitbucketServiceMockFolder/getIssueResponse';
import { getIssuesResponse } from '../git/__MOCKS__/bitbucketServiceMockFolder/getIssuesResponse';
import { getPullCommits } from '../git/__MOCKS__/bitbucketServiceMockFolder/getPullCommits';
import { getPullRequestResponse } from '../git/__MOCKS__/bitbucketServiceMockFolder/getPullRequestResponse';
import {
getOpenPullRequestsResponse,
getMergedPullRequestsResponse,
getAllPullrequestsResponse,
} from '../git/__MOCKS__/bitbucketServiceMockFolder/getPullRequestsResponse';
import { BitbucketService } from './BitbucketService';
import { getRepoCommits } from '../git/__MOCKS__/bitbucketServiceMockFolder/getRepoCommits';
import { getRepoCommit } from '../git/__MOCKS__/bitbucketServiceMockFolder/getRepoCommit';
import { BitbucketPullRequestState, VCSService } from '../git/IVCSService';
import { VCSServicesUtils } from '../git/VCSServicesUtils';
import util from 'util';
import { getRepoCommits } from '../git/__MOCKS__/bitbucketServiceMockFolder/getRepoCommits';
import { BitbucketService } from './BitbucketService';

describe('Bitbucket Service', () => {
let service: BitbucketService;
Expand All @@ -36,6 +30,7 @@ describe('Bitbucket Service', () => {
bitbucketNock.getApiResponse('pullrequests');

const response = await service.getPullRequests('pypy', 'pypy');
const getOpenPullRequestsResponse = bitbucketNock.mockBitbucketPullRequestResponse(BitbucketPullRequestState.open);
expect(response).toMatchObject(getOpenPullRequestsResponse);
});

Expand All @@ -47,10 +42,15 @@ describe('Bitbucket Service', () => {
bitbucketNock.getApiResponse('pullrequests', undefined, undefined, state);

const response = await service.getPullRequests('pypy', 'pypy', { filter: { state: PullRequestState.all } });
expect(response).toMatchObject(getAllPullrequestsResponse);
const allPullrequestsResponse = bitbucketNock.mockBitbucketPullRequestResponse(state);

expect(response).toMatchObject(allPullrequestsResponse);
});

it('returns pull request in own interface', async () => {
nock(bitbucketNock.url)
.get('/users/pypy')
.reply(200);
bitbucketNock.getApiResponse('pullrequests', 1);

const response = await service.getPullRequest('pypy', 'pypy', 1);
Expand Down Expand Up @@ -98,6 +98,8 @@ describe('Bitbucket Service', () => {
bitbucketNock.getApiResponse('pullrequests', undefined, undefined, BitbucketPullRequestState.closed);

const response = await service.getPullRequests('pypy', 'pypy', state);
const getMergedPullRequestsResponse = bitbucketNock.mockBitbucketPullRequestResponse(BitbucketPullRequestState.closed);

expect(response).toMatchObject(getMergedPullRequestsResponse);
});

Expand Down

0 comments on commit 1b6be4a

Please sign in to comment.