|
1 | 1 | import { describe, expect, it } from 'vitest' |
2 | 2 | import { featureDefinitions } from '../constants/config.js' |
3 | 3 | import { |
| 4 | + deriveStepDisplay, |
4 | 5 | getPackagesToRemove, |
5 | 6 | getPostInstallMessages, |
6 | 7 | isFeatureSelected, |
@@ -114,3 +115,53 @@ describe('getPostInstallMessages', () => { |
114 | 115 | expect(result).toEqual([]) |
115 | 116 | }) |
116 | 117 | }) |
| 118 | + |
| 119 | +describe('deriveStepDisplay', () => { |
| 120 | + it('shows all steps as completed when done', () => { |
| 121 | + const result = deriveStepDisplay(['Step 1', 'Step 2', 'Step 3'], 'done') |
| 122 | + |
| 123 | + expect(result.completedSteps).toEqual(['Step 1', 'Step 2', 'Step 3']) |
| 124 | + expect(result.currentStep).toBeUndefined() |
| 125 | + expect(result.failedStep).toBeUndefined() |
| 126 | + }) |
| 127 | + |
| 128 | + it('shows last step as current when running', () => { |
| 129 | + const result = deriveStepDisplay(['Step 1', 'Step 2', 'Step 3'], 'running') |
| 130 | + |
| 131 | + expect(result.completedSteps).toEqual(['Step 1', 'Step 2']) |
| 132 | + expect(result.currentStep).toBe('Step 3') |
| 133 | + expect(result.failedStep).toBeUndefined() |
| 134 | + }) |
| 135 | + |
| 136 | + it('shows last step as failed when error', () => { |
| 137 | + const result = deriveStepDisplay(['Step 1', 'Step 2', 'Step 3'], 'error') |
| 138 | + |
| 139 | + expect(result.completedSteps).toEqual(['Step 1', 'Step 2']) |
| 140 | + expect(result.currentStep).toBeUndefined() |
| 141 | + expect(result.failedStep).toBe('Step 3') |
| 142 | + }) |
| 143 | + |
| 144 | + it('handles empty steps on error', () => { |
| 145 | + const result = deriveStepDisplay([], 'error') |
| 146 | + |
| 147 | + expect(result.completedSteps).toEqual([]) |
| 148 | + expect(result.currentStep).toBeUndefined() |
| 149 | + expect(result.failedStep).toBeUndefined() |
| 150 | + }) |
| 151 | + |
| 152 | + it('handles single step running', () => { |
| 153 | + const result = deriveStepDisplay(['Step 1'], 'running') |
| 154 | + |
| 155 | + expect(result.completedSteps).toEqual([]) |
| 156 | + expect(result.currentStep).toBe('Step 1') |
| 157 | + expect(result.failedStep).toBeUndefined() |
| 158 | + }) |
| 159 | + |
| 160 | + it('handles single step error', () => { |
| 161 | + const result = deriveStepDisplay(['Step 1'], 'error') |
| 162 | + |
| 163 | + expect(result.completedSteps).toEqual([]) |
| 164 | + expect(result.currentStep).toBeUndefined() |
| 165 | + expect(result.failedStep).toBe('Step 1') |
| 166 | + }) |
| 167 | +}) |
0 commit comments