remove unecessary Step class

This commit is contained in:
Julien Calixte
2023-04-11 23:06:44 +02:00
parent 058046ad1f
commit c8722cad06
6 changed files with 21 additions and 40 deletions

View File

@@ -1,14 +1,13 @@
import type { Stepable } from '@/modules/task/interfaces/stepable'
import { Step } from '@/modules/task/models/step'
import { faker } from '@faker-js/faker'
export const createStepFixture = (partialStep?: Partial<Stepable>) =>
new Step(
partialStep?.id ?? faker.datatype.uuid(),
partialStep?.title ?? faker.animal.bird(),
export const createStepFixture = (partialStep?: Partial<Stepable>) => ({
id: partialStep?.id ?? faker.datatype.uuid(),
title: partialStep?.title ?? faker.animal.bird(),
estimation:
partialStep?.estimation ??
faker.datatype.number({
min: 0,
max: 40
})
)
faker.datatype.number({
min: 0,
max: 40
})
})

View File

@@ -1,17 +0,0 @@
import type { Stepable } from '@/modules/task/interfaces/stepable'
export class Step implements Stepable {
constructor(
readonly id: string,
readonly title: string,
readonly estimation: number
) {
return this
}
public static fromStepable(...stepables: Stepable[]): Step[] {
return stepables.map(
(stepable) => new Step(stepable.id, stepable.title, stepable.estimation)
)
}
}

View File

@@ -1,17 +1,16 @@
import type { Stepable } from '@/modules/task/interfaces/stepable'
import type { Taskable } from '@/modules/task/interfaces/taskable'
import { Step } from '@/modules/task/models/step'
import { toISODate } from '@/shared/types/date'
export class Task implements Taskable {
public date = toISODate(new Date())
public steps: Step[] = []
public steps: Stepable[] = []
public link: string | null = null
constructor(public readonly id: string, public readonly title: string) {}
public addSteps(...steps: Stepable[]) {
this.steps.push(...Step.fromStepable(...steps))
this.steps.push(...steps)
return this
}