@@ -2,25 +2,33 @@ import GetStepDuration from '../../src/Application/GetStepDuration';
22import StepId from "../../src/Domain/StepId" ;
33import VideoStep from "../../src/Domain/VideoStep" ;
44import QuizStep from "../../src/Domain/QuizStep" ;
5+ import Step from "../../src/Domain/Step" ;
6+ import StepRepository from "../../src/Domain/StepRepository" ;
57
6- test ( 'should get the video step duration' , ( ) => {
8+ test ( 'should get video step duration' , ( ) => {
79 const stepId = new StepId ( 'stepId' )
810 const step = new VideoStep ( stepId , 13 )
9- const stepRepository = {
10- find : jest . fn ( ( ) => step )
11- }
11+ const stepRepository = stepRepositoryWith ( step )
1212 const getStepDuration = new GetStepDuration ( stepRepository )
1313
14- expect ( getStepDuration . execute ( stepId . value ( ) ) ) . toBe ( 14.3 )
14+ const duration = getStepDuration . execute ( stepId . value ( ) )
15+
16+ expect ( duration ) . toBe ( 14.3 )
1517} ) ;
1618
17- test ( 'should get the quiz step duration' , ( ) => {
19+ test ( 'should get quiz step duration' , ( ) => {
1820 const stepId = new StepId ( 'stepId' )
1921 const step = new QuizStep ( stepId , 5 )
20- const stepRepository = {
21- find : jest . fn ( ( ) => step )
22- }
22+ const stepRepository = stepRepositoryWith ( step )
2323 const getStepDuration = new GetStepDuration ( stepRepository )
2424
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