pl-plan-list-tabs.test.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import assert from 'node:assert/strict'
  2. import { describe, it } from 'node:test'
  3. import {
  4. PL_PLAN_LIST_TABS,
  5. isPlPlanFollowStatusListTab,
  6. plPlanListTabToFilters
  7. } from './pl-display'
  8. describe('PL_PLAN_LIST_TABS', () => {
  9. it('places arranged immediately after pending_arrange', () => {
  10. const names = PL_PLAN_LIST_TABS.map((t) => t.name)
  11. assert.deepEqual(names.slice(0, 3), ['pending_arrange', 'arranged', 'drafting'])
  12. assert.equal(
  13. PL_PLAN_LIST_TABS.find((t) => t.name === 'arranged')?.label,
  14. '已安排'
  15. )
  16. })
  17. })
  18. describe('isPlPlanFollowStatusListTab', () => {
  19. it('recognizes pending_arrange, arranged, drafting', () => {
  20. assert.equal(isPlPlanFollowStatusListTab('pending_arrange'), true)
  21. assert.equal(isPlPlanFollowStatusListTab('arranged'), true)
  22. assert.equal(isPlPlanFollowStatusListTab('drafting'), true)
  23. assert.equal(isPlPlanFollowStatusListTab('all'), false)
  24. assert.equal(isPlPlanFollowStatusListTab('inbound'), false)
  25. })
  26. })
  27. describe('plPlanListTabToFilters', () => {
  28. it('maps arranged to followStatus arranged with empty planType', () => {
  29. assert.deepEqual(plPlanListTabToFilters('arranged'), {
  30. planType: '',
  31. followStatus: 'arranged'
  32. })
  33. })
  34. it('keeps pending_arrange and drafting behavior', () => {
  35. assert.deepEqual(plPlanListTabToFilters('pending_arrange'), {
  36. planType: '',
  37. followStatus: 'pending_arrange'
  38. })
  39. assert.deepEqual(plPlanListTabToFilters('drafting'), {
  40. planType: '',
  41. followStatus: 'drafting'
  42. })
  43. })
  44. it('maps type tabs without followStatus', () => {
  45. assert.deepEqual(plPlanListTabToFilters('all'), { planType: '' })
  46. assert.deepEqual(plPlanListTabToFilters('inbound'), { planType: 'inbound' })
  47. })
  48. })