Skip to content

Commit e5f3274

Browse files
committed
refactor
1 parent 8488517 commit e5f3274

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

examples/typescript/ts-step_shotgun_surgery-01_base/src/Domain/StepId.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
class StepId {
2-
constructor(private stepId: string) {
3-
}
2+
constructor(private stepId: string) {}
43

54
value(): string {
65
return this.stepId

examples/typescript/ts-step_shotgun_surgery-01_base/tests/Application/GetStepDuration.test.ts

+19-11
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,33 @@ import GetStepDuration from '../../src/Application/GetStepDuration';
22
import StepId from "../../src/Domain/StepId";
33
import VideoStep from "../../src/Domain/VideoStep";
44
import 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

Comments
 (0)