Skip to content

Commit

Permalink
feat: ✨ add TaskStatusEnum
Browse files Browse the repository at this point in the history
  • Loading branch information
zhumeisongsong committed Dec 11, 2024
1 parent 8a3b013 commit 4c2737f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libs/tasks/domain/src/index.ts
Original file line number Diff line number Diff line change
@@ -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';
20 changes: 20 additions & 0 deletions libs/tasks/domain/src/lib/value-objects/task-status.enum.spec.ts
Original file line number Diff line number Diff line change
@@ -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();
});
});
7 changes: 7 additions & 0 deletions libs/tasks/domain/src/lib/value-objects/task-status.enum.ts
Original file line number Diff line number Diff line change
@@ -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];

0 comments on commit 4c2737f

Please sign in to comment.