@@ -2,25 +2,33 @@ import GetStepDuration from '../../src/Application/GetStepDuration';
2
2
import StepId from "../../src/Domain/StepId" ;
3
3
import VideoStep from "../../src/Domain/VideoStep" ;
4
4
import QuizStep from "../../src/Domain/QuizStep" ;
5
+ import Step from "../../src/Domain/Step" ;
6
+ import StepRepository from "../../src/Domain/StepRepository" ;
5
7
6
- test ( 'should get the video step duration' , ( ) => {
8
+ test ( 'should get video step duration' , ( ) => {
7
9
const stepId = new StepId ( 'stepId' )
8
10
const step = new VideoStep ( stepId , 13 )
9
- const stepRepository = {
10
- find : jest . fn ( ( ) => step )
11
- }
11
+ const stepRepository = stepRepositoryWith ( step )
12
12
const getStepDuration = new GetStepDuration ( stepRepository )
13
13
14
- expect ( getStepDuration . execute ( stepId . value ( ) ) ) . toBe ( 14.3 )
14
+ const duration = getStepDuration . execute ( stepId . value ( ) )
15
+
16
+ expect ( duration ) . toBe ( 14.3 )
15
17
} ) ;
16
18
17
- test ( 'should get the quiz step duration' , ( ) => {
19
+ test ( 'should get quiz step duration' , ( ) => {
18
20
const stepId = new StepId ( 'stepId' )
19
21
const step = new QuizStep ( stepId , 5 )
20
- const stepRepository = {
21
- find : jest . fn ( ( ) => step )
22
- }
22
+ const stepRepository = stepRepositoryWith ( step )
23
23
const getStepDuration = new GetStepDuration ( stepRepository )
24
24
25
- expect ( getStepDuration . execute ( stepId . value ( ) ) ) . toBe ( 37.5 )
26
- } ) ;
25
+ const duration = getStepDuration . execute ( stepId . value ( ) )
26
+
27
+ expect ( duration ) . toBe ( 37.5 )
28
+ } ) ;
29
+
30
+ function stepRepositoryWith ( step : Step ) : StepRepository {
31
+ return {
32
+ find : jest . fn ( ( ) => step )
33
+ }
34
+ }
0 commit comments