import { describe, expect, it } from 'vitest'
import { calculateAP } from './useFMEA'

describe('calculateAP — AIAG-VDA 2019 Handbook Action Priority', () => {
  it('returns H for severity 10 with mid occurrence', () => {
    expect(calculateAP(10, 5, 5)).toBe('H')
  })

  it('returns H for severity 9 with low detection', () => {
    expect(calculateAP(9, 4, 7)).toBe('H')
  })

  it('returns M for severity 9 with low occurrence and good detection', () => {
    expect(calculateAP(9, 2, 5)).toBe('M')
  })

  it('returns L for severity 9 with very low occurrence and detection', () => {
    expect(calculateAP(9, 1, 4)).toBe('L')
  })

  it('returns H for severity 7 with high occurrence', () => {
    expect(calculateAP(7, 5, 1)).toBe('H')
  })

  it('returns M for severity 7 with mid occurrence', () => {
    expect(calculateAP(7, 3, 5)).toBe('M')
  })

  it('returns L for low-severity well-controlled mode', () => {
    expect(calculateAP(3, 1, 1)).toBe('L')
  })

  it('returns L for severity 5 with very low occurrence and detection', () => {
    expect(calculateAP(5, 1, 1)).toBe('L')
  })
})
