import { describe, it, expect } from 'vitest'
import { totalSkippedFromCommit, criticalReferenceGaps, referenceStateReady } from './csv-import-commit-metrics'

describe('csv-import-commit-metrics', () => {

describe('totalSkippedFromCommit', () => {
    it('devuelve 0 si recibe null', () => {
        expect(totalSkippedFromCommit(null)).toBe(0)
    })
    it('devuelve 0 si recibe objeto vacío', () => {
        expect(totalSkippedFromCommit({})).toBe(0)
    })
    it('suma los campos skipped correctamente', () => {
        expect(totalSkippedFromCommit({skipped_invalid: 2, skipped_duplicate: 3})).toBe(5)
    })
})

describe('criticalReferenceGaps', () => {
    it('devuelve 0 si recibe null', () => {
        expect(criticalReferenceGaps(null)).toBe(0)
    })
    it('devuelve 0 si recibe objeto vacío', () => {
        expect(criticalReferenceGaps({})).toBe(0)
    })
    it('devuelve el valor del campo', () => {
        expect(criticalReferenceGaps({ critical_reference_gaps: 4 })).toBe(4)
    })
})
describe('referenceStateReady', () => {
    it('devuelve true si recibe null', () => {
        expect(referenceStateReady(null)).toBe(true)
    })
    it('devuelve true si reference_state_ready es true', () => {
        expect(referenceStateReady({ reference_state_ready: true })).toBe(true)
    })
    it('devuelve false si reference_state_ready es false', () => {
        expect(referenceStateReady({ reference_state_ready: false })).toBe(false)
    })
    it('devuelve true si critical_reference_gaps es 0', () => {
        expect(referenceStateReady({ critical_reference_gaps: 0 })).toBe(true)
    })
    it('devuelve false si critical_reference_gaps es mayor a 0', () => {
        expect(referenceStateReady({ critical_reference_gaps: 2 })).toBe(false)
    })
})
})