♻️ (task) title is now mandatory in constructor
This commit is contained in:
@@ -8,7 +8,7 @@ describe('Task', () => {
|
|||||||
it('has a simple id', () => {
|
it('has a simple id', () => {
|
||||||
const uuid = faker.datatype.uuid()
|
const uuid = faker.datatype.uuid()
|
||||||
|
|
||||||
const task = new Task(uuid)
|
const task = new Task(uuid, faker.animal.bear())
|
||||||
|
|
||||||
expect(task.id).equals(uuid)
|
expect(task.id).equals(uuid)
|
||||||
})
|
})
|
||||||
@@ -26,7 +26,7 @@ describe('Task', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('adds steps and removes them', () => {
|
it('adds steps and removes them', () => {
|
||||||
const task = new Task(faker.datatype.uuid())
|
const task = new Task(faker.datatype.uuid(), faker.color.human())
|
||||||
|
|
||||||
const [firstStep, secondStep] = [createStepFixture(), createStepFixture()]
|
const [firstStep, secondStep] = [createStepFixture(), createStepFixture()]
|
||||||
|
|
||||||
@@ -42,10 +42,7 @@ describe('Task', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('must have an id, a title and steps to be valid', () => {
|
it('must have an id, a title and steps to be valid', () => {
|
||||||
const task = new Task(faker.datatype.uuid())
|
const task = new Task(faker.datatype.uuid(), faker.color.human())
|
||||||
expect(Task.validate(task)).toEqual(false)
|
|
||||||
|
|
||||||
task.title = faker.animal.bird()
|
|
||||||
expect(Task.validate(task)).toEqual(false)
|
expect(Task.validate(task)).toEqual(false)
|
||||||
|
|
||||||
task.addSteps(createStepFixture())
|
task.addSteps(createStepFixture())
|
||||||
@@ -53,7 +50,7 @@ describe('Task', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('calculates the total estimation of steps', () => {
|
it('calculates the total estimation of steps', () => {
|
||||||
const task = new Task(faker.datatype.uuid())
|
const task = new Task(faker.datatype.uuid(), faker.color.human())
|
||||||
|
|
||||||
task.addSteps(
|
task.addSteps(
|
||||||
createStepFixture({ estimation: 1 }),
|
createStepFixture({ estimation: 1 }),
|
||||||
|
|||||||
@@ -4,10 +4,9 @@ import { Step } from '@/use-cases/task/models/step'
|
|||||||
|
|
||||||
export class Task implements Taskable {
|
export class Task implements Taskable {
|
||||||
public steps: Step[] = []
|
public steps: Step[] = []
|
||||||
public title = ''
|
|
||||||
public link: string | null = null
|
public link: string | null = null
|
||||||
|
|
||||||
constructor(public readonly id: string) {}
|
constructor(public readonly id: string, public readonly title: string) {}
|
||||||
|
|
||||||
public addSteps(...steps: Stepable[]) {
|
public addSteps(...steps: Stepable[]) {
|
||||||
this.steps.push(...Step.fromStepable(...steps))
|
this.steps.push(...Step.fromStepable(...steps))
|
||||||
@@ -32,8 +31,7 @@ export class Task implements Taskable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static fromTaskable(taskable: Taskable) {
|
public static fromTaskable(taskable: Taskable) {
|
||||||
const task = new Task(taskable.id)
|
const task = new Task(taskable.id, taskable.title)
|
||||||
task.title = taskable.title
|
|
||||||
task.link = taskable.link
|
task.link = taskable.link
|
||||||
task.addSteps(...taskable.steps)
|
task.addSteps(...taskable.steps)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user