enums.test.ts 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. import { describe, it, expect } from 'vitest';
  2. import {
  3. DisabilityType,
  4. DisabilityTypeLabels,
  5. DISABILITY_TYPES,
  6. DisabilityLevel,
  7. DisabilityLevelLabels,
  8. DISABILITY_LEVELS,
  9. OrderStatus,
  10. OrderStatusLabels,
  11. OrderStatusDescriptions,
  12. ORDER_STATUSES,
  13. WorkStatus,
  14. WorkStatusLabels,
  15. WorkStatusDescriptions,
  16. WORK_STATUSES
  17. } from '../../src/index.js';
  18. describe('Allin系统枚举常量', () => {
  19. describe('残疾类型枚举 (DisabilityType)', () => {
  20. it('应该包含7个有效的残疾类型值', () => {
  21. expect(DISABILITY_TYPES).toHaveLength(7);
  22. expect(DISABILITY_TYPES).toEqual([
  23. DisabilityType.VISION,
  24. DisabilityType.HEARING,
  25. DisabilityType.SPEECH,
  26. DisabilityType.PHYSICAL,
  27. DisabilityType.INTELLECTUAL,
  28. DisabilityType.MENTAL,
  29. DisabilityType.MULTIPLE
  30. ]);
  31. });
  32. it('应该与数据库原始值一致(小写字符串)', () => {
  33. expect(DisabilityType.VISION).toBe('vision');
  34. expect(DisabilityType.HEARING).toBe('hearing');
  35. expect(DisabilityType.SPEECH).toBe('speech');
  36. expect(DisabilityType.PHYSICAL).toBe('physical');
  37. expect(DisabilityType.INTELLECTUAL).toBe('intellectual');
  38. expect(DisabilityType.MENTAL).toBe('mental');
  39. expect(DisabilityType.MULTIPLE).toBe('multiple');
  40. });
  41. it('应该有正确的中文标签映射', () => {
  42. expect(DisabilityTypeLabels[DisabilityType.VISION]).toBe('视力残疾');
  43. expect(DisabilityTypeLabels[DisabilityType.HEARING]).toBe('听力残疾');
  44. expect(DisabilityTypeLabels[DisabilityType.SPEECH]).toBe('言语残疾');
  45. expect(DisabilityTypeLabels[DisabilityType.PHYSICAL]).toBe('肢体残疾');
  46. expect(DisabilityTypeLabels[DisabilityType.INTELLECTUAL]).toBe('智力残疾');
  47. expect(DisabilityTypeLabels[DisabilityType.MENTAL]).toBe('精神残疾');
  48. expect(DisabilityTypeLabels[DisabilityType.MULTIPLE]).toBe('多重残疾');
  49. });
  50. });
  51. describe('残疾等级枚举 (DisabilityLevel)', () => {
  52. it('应该包含4个有效的残疾等级值', () => {
  53. expect(DISABILITY_LEVELS).toHaveLength(4);
  54. expect(DISABILITY_LEVELS).toEqual([
  55. DisabilityLevel.ONE,
  56. DisabilityLevel.TWO,
  57. DisabilityLevel.THREE,
  58. DisabilityLevel.FOUR
  59. ]);
  60. });
  61. it('应该与数据库原始值一致(数字1-4)', () => {
  62. expect(DisabilityLevel.ONE).toBe(1);
  63. expect(DisabilityLevel.TWO).toBe(2);
  64. expect(DisabilityLevel.THREE).toBe(3);
  65. expect(DisabilityLevel.FOUR).toBe(4);
  66. });
  67. it('应该有正确的中文标签映射', () => {
  68. expect(DisabilityLevelLabels[DisabilityLevel.ONE]).toBe('一级');
  69. expect(DisabilityLevelLabels[DisabilityLevel.TWO]).toBe('二级');
  70. expect(DisabilityLevelLabels[DisabilityLevel.THREE]).toBe('三级');
  71. expect(DisabilityLevelLabels[DisabilityLevel.FOUR]).toBe('四级');
  72. });
  73. });
  74. describe('订单状态枚举 (OrderStatus)', () => {
  75. it('应该包含5个有效的订单状态值', () => {
  76. expect(ORDER_STATUSES).toHaveLength(5);
  77. expect(ORDER_STATUSES).toEqual([
  78. OrderStatus.DRAFT,
  79. OrderStatus.CONFIRMED,
  80. OrderStatus.IN_PROGRESS,
  81. OrderStatus.COMPLETED,
  82. OrderStatus.CANCELLED
  83. ]);
  84. });
  85. it('应该与数据库原始值一致(小写字符串,下划线分隔)', () => {
  86. expect(OrderStatus.DRAFT).toBe('draft');
  87. expect(OrderStatus.CONFIRMED).toBe('confirmed');
  88. expect(OrderStatus.IN_PROGRESS).toBe('in_progress');
  89. expect(OrderStatus.COMPLETED).toBe('completed');
  90. expect(OrderStatus.CANCELLED).toBe('cancelled');
  91. });
  92. it('应该有正确的中文标签映射', () => {
  93. expect(OrderStatusLabels[OrderStatus.DRAFT]).toBe('草稿');
  94. expect(OrderStatusLabels[OrderStatus.CONFIRMED]).toBe('已确认');
  95. expect(OrderStatusLabels[OrderStatus.IN_PROGRESS]).toBe('进行中');
  96. expect(OrderStatusLabels[OrderStatus.COMPLETED]).toBe('已完成');
  97. expect(OrderStatusLabels[OrderStatus.CANCELLED]).toBe('已取消');
  98. });
  99. it('应该有正确的业务含义描述', () => {
  100. expect(OrderStatusDescriptions[OrderStatus.DRAFT]).toBe('订单已创建但未提交,可继续编辑');
  101. expect(OrderStatusDescriptions[OrderStatus.CONFIRMED]).toBe('订单已提交并确认,等待执行');
  102. expect(OrderStatusDescriptions[OrderStatus.IN_PROGRESS]).toBe('订单正在执行中,相关人员正在处理');
  103. expect(OrderStatusDescriptions[OrderStatus.COMPLETED]).toBe('订单已成功完成,所有工作已结束');
  104. expect(OrderStatusDescriptions[OrderStatus.CANCELLED]).toBe('订单已被取消,不再执行');
  105. });
  106. });
  107. describe('工作状态枚举 (WorkStatus)', () => {
  108. it('应该包含4个有效的工作状态值', () => {
  109. expect(WORK_STATUSES).toHaveLength(4);
  110. expect(WORK_STATUSES).toEqual([
  111. WorkStatus.NOT_WORKING,
  112. WorkStatus.PRE_WORKING,
  113. WorkStatus.WORKING,
  114. WorkStatus.RESIGNED
  115. ]);
  116. });
  117. it('应该与数据库原始值一致(小写字符串,下划线分隔)', () => {
  118. expect(WorkStatus.NOT_WORKING).toBe('not_working');
  119. expect(WorkStatus.PRE_WORKING).toBe('pre_working');
  120. expect(WorkStatus.WORKING).toBe('working');
  121. expect(WorkStatus.RESIGNED).toBe('resigned');
  122. });
  123. it('应该有正确的中文标签映射', () => {
  124. expect(WorkStatusLabels[WorkStatus.NOT_WORKING]).toBe('未就业');
  125. expect(WorkStatusLabels[WorkStatus.PRE_WORKING]).toBe('待就业');
  126. expect(WorkStatusLabels[WorkStatus.WORKING]).toBe('已就业');
  127. expect(WorkStatusLabels[WorkStatus.RESIGNED]).toBe('已离职');
  128. });
  129. it('应该有正确的业务含义描述', () => {
  130. expect(WorkStatusDescriptions[WorkStatus.NOT_WORKING]).toBe('尚未开始工作,正在寻找就业机会');
  131. expect(WorkStatusDescriptions[WorkStatus.PRE_WORKING]).toBe('已安排工作但尚未入职,等待入职手续');
  132. expect(WorkStatusDescriptions[WorkStatus.WORKING]).toBe('正在工作中,处于在职状态');
  133. expect(WorkStatusDescriptions[WorkStatus.RESIGNED]).toBe('工作已结束,已离职');
  134. });
  135. });
  136. });