import { describe, expect, it } from 'vitest'
import { nextDevVersion } from '../version.js'

describe('nextDevVersion — 4.x finish-version-bumping (from the RELEASED version)', () => {
  it('release bumps minor and resets patch', () => {
    expect(nextDevVersion('5.1.0', 'release')).toBe('5.2.0')
    expect(nextDevVersion('5.0.0', 'release')).toBe('5.1.0')
    expect(nextDevVersion('4.81.0', 'release')).toBe('4.82.0')
  })

  it('hotfix bumps patch by TWO (patch+1 consumed by the tag, +1 free for next hotfix)', () => {
    expect(nextDevVersion('5.0.1', 'hotfix')).toBe('5.0.3')
    expect(nextDevVersion('5.0.0', 'hotfix')).toBe('5.0.2')
    expect(nextDevVersion('4.81.4', 'hotfix')).toBe('4.81.6')
  })

  it('strips a leading v', () => {
    expect(nextDevVersion('v5.1.0', 'release')).toBe('5.2.0')
    expect(nextDevVersion('v5.0.1', 'hotfix')).toBe('5.0.3')
  })

  it('treats unknown branch types like a release (minor bump)', () => {
    expect(nextDevVersion('5.1.0', 'other')).toBe('5.2.0')
  })

  it('is defensive against short/partial versions', () => {
    expect(nextDevVersion('5', 'release')).toBe('5.1.0') // 5.0.0 → minor+1
    expect(nextDevVersion('5.2', 'hotfix')).toBe('5.2.2') // 5.2.0 → patch+2
  })
})
