-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: test for mocking frameworks practice
- Loading branch information
ryzzaki
committed
Jan 23, 2020
1 parent
0453a03
commit ea6b972
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
src/practices/Java/JavaMockingFrameworkUsedPractice.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { JavaMockingFrameworkUsedPractice } from './JavaMockingFrameworkUsed'; | ||
import { PracticeEvaluationResult, ProgrammingLanguage } from '../../model'; | ||
import { TestContainerContext, createTestContainer } from '../../inversify.config'; | ||
import { IPackageInspector } from '../../inspectors/IPackageInspector'; | ||
|
||
describe('JavaMockingFrameworkUsedPractice', () => { | ||
let practice: JavaMockingFrameworkUsedPractice; | ||
let containerCtx: TestContainerContext; | ||
let packageInspector: IPackageInspector; | ||
|
||
beforeAll(() => { | ||
containerCtx = createTestContainer(); | ||
containerCtx.container.bind('JavaMockingFrameworkUsedPractice').to(JavaMockingFrameworkUsedPractice); | ||
practice = containerCtx.container.get('JavaMockingFrameworkUsedPractice'); | ||
packageInspector = <IPackageInspector>containerCtx.practiceContext.packageInspector; | ||
}); | ||
|
||
it('Detects Java Mocking framework', async () => { | ||
packageInspector.hasOneOfPackages = () => true; | ||
|
||
const result = await practice.evaluate(containerCtx.practiceContext); | ||
expect(result).toEqual(PracticeEvaluationResult.practicing); | ||
}); | ||
|
||
it('Did not detect Java Mocking framework', async () => { | ||
packageInspector.hasOneOfPackages = () => false; | ||
|
||
const result = await practice.evaluate(containerCtx.practiceContext); | ||
expect(result).toEqual(PracticeEvaluationResult.notPracticing); | ||
}); | ||
|
||
it('Did not recognize packageInspector', async () => { | ||
const result = await practice.evaluate({ ...containerCtx.practiceContext, packageInspector: undefined }); | ||
expect(result).toEqual(PracticeEvaluationResult.unknown); | ||
}); | ||
|
||
it('Is applicable if it is Java', async () => { | ||
containerCtx.practiceContext.projectComponent.language = ProgrammingLanguage.Java; | ||
|
||
const result = await practice.isApplicable(containerCtx.practiceContext); | ||
expect(result).toEqual(true); | ||
}); | ||
|
||
it('Is applicable if it is not Java', async () => { | ||
containerCtx.practiceContext.projectComponent.language = ProgrammingLanguage.Python; | ||
|
||
const result = await practice.isApplicable(containerCtx.practiceContext); | ||
expect(result).toEqual(false); | ||
}); | ||
}); |