Skip to content

Commit

Permalink
add application service
Browse files Browse the repository at this point in the history
  • Loading branch information
santakadev committed Apr 16, 2021
1 parent 2634a94 commit 4069df1
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 15 deletions.
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
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
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
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

This file was deleted.

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)
});

This file was deleted.

0 comments on commit 4069df1

Please sign in to comment.