From 1141cad8c7b1e71cef5202b95723a50346180b66 Mon Sep 17 00:00:00 2001 From: Adela Homolova Date: Mon, 9 Dec 2019 14:35:20 +0100 Subject: [PATCH] fix: rebind IContentRepositoryBrowser in practice instead of binding in inversify.config.ts --- src/inspectors/CollaborationInspector.spec.ts | 3 +-- src/inspectors/IssueTrackingInspector.spec.ts | 3 +-- src/inversify.config.ts | 4 +--- src/practices/LanguageIndependent/DoesPullRequests.spec.ts | 3 +-- .../TimeToSolvePullRequestsPractice.spec.ts | 7 ++++--- 5 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/inspectors/CollaborationInspector.spec.ts b/src/inspectors/CollaborationInspector.spec.ts index 5d8a370f9..9293126db 100644 --- a/src/inspectors/CollaborationInspector.spec.ts +++ b/src/inspectors/CollaborationInspector.spec.ts @@ -17,8 +17,7 @@ describe('Collaboration Inspector', () => { let containerCtx: TestContainerContext; beforeAll(async () => { - const args = { uri: 'https://github.com/octocat/Hello-World' }; - containerCtx = createTestContainer(args); + containerCtx = createTestContainer(); inspector = containerCtx.practiceContext.collaborationInspector; }); diff --git a/src/inspectors/IssueTrackingInspector.spec.ts b/src/inspectors/IssueTrackingInspector.spec.ts index 937a052f8..26ea260ef 100644 --- a/src/inspectors/IssueTrackingInspector.spec.ts +++ b/src/inspectors/IssueTrackingInspector.spec.ts @@ -16,8 +16,7 @@ describe('Issue Tracking Inspector', () => { let containerCtx: TestContainerContext; beforeAll(async () => { - const args = { uri: 'https://github.com/octocat/Hello-World' }; - containerCtx = createTestContainer(args); + containerCtx = createTestContainer(); inspector = containerCtx.practiceContext.issueTrackingInspector; }); diff --git a/src/inversify.config.ts b/src/inversify.config.ts index 604d922ec..7328e7cf1 100644 --- a/src/inversify.config.ts +++ b/src/inversify.config.ts @@ -70,9 +70,7 @@ export const createTestContainer = ( // FileSystemService as default ProjectBrowser container.bind(Types.IProjectFilesBrowser).toConstantValue(vfss); - args?.uri.includes('github') - ? container.bind(Types.IContentRepositoryBrowser).to(GitHubService) - : container.bind(Types.IContentRepositoryBrowser).to(BitbucketService); + container.bind(Types.IContentRepositoryBrowser).to(GitHubService); container.bind(Types.IFileInspector).to(FileInspector); container.bind(Types.IPackageInspector).to(JavaScriptPackageInspector); container.bind(Types.ICollaborationInspector).to(CollaborationInspector); diff --git a/src/practices/LanguageIndependent/DoesPullRequests.spec.ts b/src/practices/LanguageIndependent/DoesPullRequests.spec.ts index 60820061c..dae0598b9 100644 --- a/src/practices/LanguageIndependent/DoesPullRequests.spec.ts +++ b/src/practices/LanguageIndependent/DoesPullRequests.spec.ts @@ -15,8 +15,7 @@ describe('DoesPullRequests', () => { }); beforeAll(() => { - const args = { uri: 'https://github.com/octocat/Hello-World' }; - containerCtx = createTestContainer(args); + containerCtx = createTestContainer(); containerCtx.container.bind('DoesPullRequests').to(DoesPullRequestsPractice); practice = containerCtx.container.get('DoesPullRequests'); }); diff --git a/src/practices/LanguageIndependent/TimeToSolvePullRequestsPractice.spec.ts b/src/practices/LanguageIndependent/TimeToSolvePullRequestsPractice.spec.ts index fb56e6cef..6d9ef739e 100644 --- a/src/practices/LanguageIndependent/TimeToSolvePullRequestsPractice.spec.ts +++ b/src/practices/LanguageIndependent/TimeToSolvePullRequestsPractice.spec.ts @@ -3,9 +3,10 @@ import nock from 'nock'; import { CollaborationInspector } from '../../inspectors'; import { createTestContainer, TestContainerContext } from '../../inversify.config'; import { PracticeEvaluationResult } from '../../model'; -import { BitbucketPullRequestState } from '../../services'; +import { BitbucketPullRequestState, BitbucketService } from '../../services'; import { BitbucketNock } from '../../test/helpers/bitbucketNock'; import { TimeToSolvePullRequestsPractice } from './TimeToSolvePullRequestsPractice'; +import { Types } from '../../types'; describe('TimeToSolvePullRequestsPractice', () => { let practice: TimeToSolvePullRequestsPractice; @@ -20,9 +21,9 @@ describe('TimeToSolvePullRequestsPractice', () => { }); beforeAll(() => { - const args = { uri: 'https://bitbucket.org/pypy/pypy' }; - containerCtx = createTestContainer(args); + containerCtx = createTestContainer(); containerCtx.container.bind('TimeToSolvePractice').to(TimeToSolvePullRequestsPractice); + containerCtx.container.rebind(Types.IContentRepositoryBrowser).to(BitbucketService); practice = containerCtx.container.get('TimeToSolvePractice'); mockCollaborationInspector = new MockedCollaborationInspector(); });