WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
File tree Expand file tree Collapse file tree 7 files changed +64
-15
lines changed
examples/typescript/ts-step_shotgun_surgery-01_base Expand file tree Collapse file tree 7 files changed +64
-15
lines changed Original file line number Diff line number Diff line change 1+ import StepId from '../Domain/StepId'
2+ import StepRepository from '../Domain/StepRepository'
3+
4+ class GetStepDuration {
5+ constructor ( private repository : StepRepository ) {
6+ }
7+
8+ execute ( stepId : string ) : number {
9+ const step = this . repository . find ( new StepId ( stepId ) )
10+ return step . getVideoDuration ( )
11+ }
12+ }
13+
14+ export default GetStepDuration
Original file line number Diff line number Diff line change 1+ import StepId from "./StepId" ;
2+
3+ class Step {
4+ constructor (
5+ private id : StepId ,
6+ private videoDuration : number
7+ ) { }
8+
9+ type ( ) : string {
10+ return 'video'
11+ }
12+
13+ getVideoDuration ( ) : number {
14+ return this . videoDuration
15+ }
16+ }
17+
18+ export default Step
Original file line number Diff line number Diff line change 1+ class StepId {
2+ constructor ( private stepId : string ) {
3+ }
4+
5+ value ( ) : string {
6+ return this . stepId
7+ }
8+ }
9+
10+ export default StepId
Original file line number Diff line number Diff line change 1+ import Step from './Step'
2+ import StepId from './StepId'
3+
4+ interface StepRepository {
5+ find ( stepId : StepId ) : Step
6+ }
7+
8+ export default StepRepository
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ import GetStepDuration from '../../src/Application/GetStepDuration' ;
2+ import StepId from "../../src/Domain/StepId" ;
3+ import Step from "../../src/Domain/Step" ;
4+
5+ test ( 'should get the video step duration' , ( ) => {
6+ const stepId = new StepId ( 'stepId' )
7+ const step = new Step ( stepId , 13 )
8+ const stepRepository = {
9+ find : jest . fn ( ( stepId : StepId ) => step )
10+ }
11+ const getStepDuration = new GetStepDuration ( stepRepository )
12+
13+ expect ( getStepDuration . execute ( stepId . value ( ) ) ) . toBe ( 13 )
14+ } ) ;
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments