From a6f465c25729de3a8fe372e2d04c9ca40d1b0098 Mon Sep 17 00:00:00 2001 From: Adela Homolova Date: Mon, 16 Dec 2019 15:32:13 +0100 Subject: [PATCH] fix: tests after refactoring --- src/inspectors/CollaborationInspector.spec.ts | 8 +++++--- .../DoesPullRequests.spec.ts | 20 ++++++++++--------- src/services/git/Git.spec.ts | 8 ++++---- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/inspectors/CollaborationInspector.spec.ts b/src/inspectors/CollaborationInspector.spec.ts index 15cae6f93..2f1168450 100644 --- a/src/inspectors/CollaborationInspector.spec.ts +++ b/src/inspectors/CollaborationInspector.spec.ts @@ -26,9 +26,11 @@ describe('Collaboration Inspector', () => { }); it('returns paginated pull requests', async () => { - 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({ + pulls: [ + { number: 1347, state: 'open', title: 'new-feature', body: 'Please pull these awesome changes', head: 'new-topic', base: 'master' }, + ], + }); const response = await inspector.getPullRequests('octocat', 'Hello-World'); expect(response).toMatchObject(getPullsServiceResponse); diff --git a/src/practices/LanguageIndependent/DoesPullRequests.spec.ts b/src/practices/LanguageIndependent/DoesPullRequests.spec.ts index dae0598b9..26905ef82 100644 --- a/src/practices/LanguageIndependent/DoesPullRequests.spec.ts +++ b/src/practices/LanguageIndependent/DoesPullRequests.spec.ts @@ -27,10 +27,12 @@ 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' }], - PullRequestState.all, - ); + new GitHubNock('1', 'octocat', 1296269, 'Hello-World').getPulls({ + pulls: [ + { number: 1347, state: 'open', title: 'new-feature', body: 'Please pull these awesome changes', head: 'new-topic', base: 'master' }, + ], + queryState: PullRequestState.all, + }); new GitHubNock('1', 'octocat', 1, 'Hello-World').getCommits().reply(200, getRepoCommitsResponse); const evaluated = await practice.evaluate(containerCtx.practiceContext); @@ -39,7 +41,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([], PullRequestState.all); + new GitHubNock('1', 'octocat', 1296269, 'Hello-World').getPulls({ pulls: [], queryState: PullRequestState.all }); new GitHubNock('1', 'octocat', 1, 'Hello-World').getCommits().reply(200, getRepoCommitsResponse); const evaluated = await practice.evaluate(containerCtx.practiceContext); @@ -48,8 +50,8 @@ 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( - [ + new GitHubNock('1', 'octocat', 1296269, 'Hello-World').getPulls({ + pulls: [ { number: 1348, state: 'opened', @@ -61,8 +63,8 @@ describe('DoesPullRequests', () => { created_at: '2000-03-06T23:06:50Z', }, ], - PullRequestState.all, - ); + queryState: PullRequestState.all, + }); new GitHubNock('1', 'octocat', 1, 'Hello-World').getCommits().reply(200, getRepoCommitsResponse); const evaluated = await practice.evaluate(containerCtx.practiceContext); diff --git a/src/services/git/Git.spec.ts b/src/services/git/Git.spec.ts index 3652863d5..51c3329ac 100644 --- a/src/services/git/Git.spec.ts +++ b/src/services/git/Git.spec.ts @@ -290,13 +290,13 @@ describe('Git', () => { describe('#getPullRequestCount', () => { it('returns the number of both open and closed pull requests', async () => { - gitHubNock.getPulls( - [ + gitHubNock.getPulls({ + pulls: [ { number: 1, state: 'open', title: '1', body: '1', head: 'head', base: 'base' }, { number: 2, state: 'closed', title: '2', body: '2', head: 'head', base: 'base' }, ], - 'all', - ); + queryState: 'all', + }); const result = await git.getPullRequestCount(); expect(result).toEqual(2);