-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2634a94
commit 4069df1
Showing
7 changed files
with
64 additions
and
15 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
examples/typescript/ts-step_shotgun_surgery-01_base/src/Application/GetStepDuration.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,14 @@ | ||
import StepId from '../Domain/StepId' | ||
import StepRepository from '../Domain/StepRepository' | ||
|
||
class GetStepDuration { | ||
constructor(private repository: StepRepository) { | ||
} | ||
|
||
execute(stepId: string): number { | ||
const step = this.repository.find(new StepId(stepId)) | ||
return step.getVideoDuration() | ||
} | ||
} | ||
|
||
export default GetStepDuration |
18 changes: 18 additions & 0 deletions
18
examples/typescript/ts-step_shotgun_surgery-01_base/src/Domain/Step.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,18 @@ | ||
import StepId from "./StepId"; | ||
|
||
class Step { | ||
constructor( | ||
private id: StepId, | ||
private videoDuration: number | ||
) {} | ||
|
||
type(): string { | ||
return 'video' | ||
} | ||
|
||
getVideoDuration(): number { | ||
return this.videoDuration | ||
} | ||
} | ||
|
||
export default Step |
10 changes: 10 additions & 0 deletions
10
examples/typescript/ts-step_shotgun_surgery-01_base/src/Domain/StepId.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,10 @@ | ||
class StepId { | ||
constructor(private stepId: string) { | ||
} | ||
|
||
value(): string { | ||
return this.stepId | ||
} | ||
} | ||
|
||
export default StepId |
8 changes: 8 additions & 0 deletions
8
examples/typescript/ts-step_shotgun_surgery-01_base/src/Domain/StepRepository.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,8 @@ | ||
import Step from './Step' | ||
import StepId from './StepId' | ||
|
||
interface StepRepository { | ||
find(stepId: StepId): Step | ||
} | ||
|
||
export default StepRepository |
9 changes: 0 additions & 9 deletions
9
examples/typescript/ts-step_shotgun_surgery-01_base/src/index.ts
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
...ples/typescript/ts-step_shotgun_surgery-01_base/tests/Application/GetStepDuration.test.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,14 @@ | ||
import GetStepDuration from '../../src/Application/GetStepDuration'; | ||
import StepId from "../../src/Domain/StepId"; | ||
import Step from "../../src/Domain/Step"; | ||
|
||
test('should get the video step duration', () => { | ||
const stepId = new StepId('stepId') | ||
const step = new Step(stepId, 13) | ||
const stepRepository = { | ||
find: jest.fn((stepId: StepId) => step) | ||
} | ||
const getStepDuration = new GetStepDuration(stepRepository) | ||
|
||
expect(getStepDuration.execute(stepId.value())).toBe(13) | ||
}); |
6 changes: 0 additions & 6 deletions
6
examples/typescript/ts-step_shotgun_surgery-01_base/tests/index.test.ts
This file was deleted.
Oops, something went wrong.