From 4c2737feee8835b932442524e9c41536e3168da4 Mon Sep 17 00:00:00 2001 From: zhumeisongsong Date: Wed, 11 Dec 2024 14:21:56 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E2=9C=A8=20add=20TaskStatusEnum?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/tasks/domain/src/index.ts | 2 ++ .../value-objects/task-status.enum.spec.ts | 20 +++++++++++++++++++ .../src/lib/value-objects/task-status.enum.ts | 7 +++++++ 3 files changed, 29 insertions(+) create mode 100644 libs/tasks/domain/src/lib/value-objects/task-status.enum.spec.ts create mode 100644 libs/tasks/domain/src/lib/value-objects/task-status.enum.ts diff --git a/libs/tasks/domain/src/index.ts b/libs/tasks/domain/src/index.ts index 99ae8ff..b6b8850 100644 --- a/libs/tasks/domain/src/index.ts +++ b/libs/tasks/domain/src/index.ts @@ -1,4 +1,6 @@ export * from './lib/entities/task.entity'; export * from './lib/entities/user-task.entity'; +export * from './lib/value-objects/task-status.enum'; + export * from './lib/tasks.repository'; diff --git a/libs/tasks/domain/src/lib/value-objects/task-status.enum.spec.ts b/libs/tasks/domain/src/lib/value-objects/task-status.enum.spec.ts new file mode 100644 index 0000000..17bd964 --- /dev/null +++ b/libs/tasks/domain/src/lib/value-objects/task-status.enum.spec.ts @@ -0,0 +1,20 @@ +import { TaskStatus } from './task-status.enum'; + +describe('TaskStatus', () => { + it('should have TODO status', () => { + expect(TaskStatus.TODO).toBe('TODO'); + }); + + it('should have IN_PROGRESS status', () => { + expect(TaskStatus.IN_PROGRESS).toBe('IN_PROGRESS'); + }); + + it('should have DONE status', () => { + expect(TaskStatus.DONE).toBe('DONE'); + }); + + it('should be immutable', () => { + // @ts-expect-error - Testing immutability + expect(() => TaskStatus.TODO = 'SOMETHING_ELSE').toThrow(); + }); +}); diff --git a/libs/tasks/domain/src/lib/value-objects/task-status.enum.ts b/libs/tasks/domain/src/lib/value-objects/task-status.enum.ts new file mode 100644 index 0000000..290cf35 --- /dev/null +++ b/libs/tasks/domain/src/lib/value-objects/task-status.enum.ts @@ -0,0 +1,7 @@ +export const TaskStatusEnum = { + TODO: 'TODO', + IN_PROGRESS: 'IN_PROGRESS', + DONE: 'DONE', +} as const; + +export type TaskStatus = (typeof TaskStatusEnum)[keyof typeof TaskStatusEnum]; From cbaecea8e906dcf558d4412f2a6858f8958001fc Mon Sep 17 00:00:00 2001 From: zhumeisongsong Date: Wed, 11 Dec 2024 14:31:09 +0900 Subject: [PATCH 2/2] =?UTF-8?q?test:=20=F0=9F=A7=AA=20pass=20test=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/src/lib/value-objects/task-status.enum.spec.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/tasks/domain/src/lib/value-objects/task-status.enum.spec.ts b/libs/tasks/domain/src/lib/value-objects/task-status.enum.spec.ts index 17bd964..515c89e 100644 --- a/libs/tasks/domain/src/lib/value-objects/task-status.enum.spec.ts +++ b/libs/tasks/domain/src/lib/value-objects/task-status.enum.spec.ts @@ -1,16 +1,16 @@ -import { TaskStatus } from './task-status.enum'; +import { TaskStatusEnum } from './task-status.enum'; describe('TaskStatus', () => { it('should have TODO status', () => { - expect(TaskStatus.TODO).toBe('TODO'); + expect(TaskStatusEnum.TODO).toBe('TODO'); }); it('should have IN_PROGRESS status', () => { - expect(TaskStatus.IN_PROGRESS).toBe('IN_PROGRESS'); + expect(TaskStatusEnum.IN_PROGRESS).toBe('IN_PROGRESS'); }); it('should have DONE status', () => { - expect(TaskStatus.DONE).toBe('DONE'); + expect(TaskStatusEnum.DONE).toBe('DONE'); }); it('should be immutable', () => {