Skip to content

Commit

Permalink
fix: add queryState to new GitHubNock()
Browse files Browse the repository at this point in the history
  • Loading branch information
adelkahomolova committed Dec 6, 2019
1 parent 7bbca3b commit 46a7a31
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions src/practices/LanguageIndependent/DoesPullRequests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { DoesPullRequestsPractice } from './DoesPullRequests';
import nock from 'nock';
import { GitHubNock } from '../../../test/helpers/gitHubNock';
import { getRepoCommitsResponse } from '../../services/git/__MOCKS__/gitHubServiceMockFolder/getRepoCommitsResponse.mock';
import { PullRequestState } from '../../inspectors/ICollaborationInspector';

describe('DoesPullRequests', () => {
let practice: DoesPullRequestsPractice;
Expand All @@ -26,9 +27,10 @@ describe('DoesPullRequests', () => {

it('return practicing if there is at least one PR which is newer than last commit in master minus 30 days', async () => {
containerCtx.practiceContext.projectComponent.repositoryPath = 'https://github.com/octocat/Hello-World';
new GitHubNock('1', 'octocat', 1296269, 'Hello-World').getPulls([
{ number: 1347, state: 'open', title: 'new-feature', body: 'Please pull these awesome changes', head: 'new-topic', base: 'master' },
]);
new GitHubNock('1', 'octocat', 1296269, 'Hello-World').getPulls(
[{ number: 1347, state: 'open', title: 'new-feature', body: 'Please pull these awesome changes', head: 'new-topic', base: 'master' }],
PullRequestState.all,
);
new GitHubNock('1', 'octocat', 1, 'Hello-World').getCommits().reply(200, getRepoCommitsResponse);

const evaluated = await practice.evaluate(containerCtx.practiceContext);
Expand All @@ -37,7 +39,7 @@ describe('DoesPullRequests', () => {

it('return notPracticing if there is no PR which is newer than last commit in master minus 30 days', async () => {
containerCtx.practiceContext.projectComponent.repositoryPath = 'https://github.com/octocat/Hello-World';
new GitHubNock('1', 'octocat', 1296269, 'Hello-World').getPulls([]);
new GitHubNock('1', 'octocat', 1296269, 'Hello-World').getPulls([], PullRequestState.all);
new GitHubNock('1', 'octocat', 1, 'Hello-World').getCommits().reply(200, getRepoCommitsResponse);

const evaluated = await practice.evaluate(containerCtx.practiceContext);
Expand All @@ -46,18 +48,21 @@ describe('DoesPullRequests', () => {

it('return notPracticing if there is PR older than 30 days than the last commit in master', async () => {
containerCtx.practiceContext.projectComponent.repositoryPath = 'https://github.com/octocat/Hello-World';
new GitHubNock('1', 'octocat', 1296269, 'Hello-World').getPulls([
{
number: 1348,
state: 'opened',
title: 'new-feature',
body: '',
head: 'new-topic',
base: 'master',
// eslint-disable-next-line @typescript-eslint/camelcase
created_at: '2000-03-06T23:06:50Z',
},
]);
new GitHubNock('1', 'octocat', 1296269, 'Hello-World').getPulls(
[
{
number: 1348,
state: 'opened',
title: 'new-feature',
body: '',
head: 'new-topic',
base: 'master',
// eslint-disable-next-line @typescript-eslint/camelcase
created_at: '2000-03-06T23:06:50Z',
},
],
PullRequestState.all,
);
new GitHubNock('1', 'octocat', 1, 'Hello-World').getCommits().reply(200, getRepoCommitsResponse);

const evaluated = await practice.evaluate(containerCtx.practiceContext);
Expand Down

0 comments on commit 46a7a31

Please sign in to comment.