import { describe, expect, it } from 'vitest'

import { buildMonitorEcgPath } from './monitorEcg'

describe('monitorEcg', () => {
  it('builds a deterministic tiled ECG path', () => {
    const first = buildMonitorEcgPath({
      segmentWidth: 100,
      height: 30,
      beatsPerSegment: 2,
      segments: 2,
      samplesPerBeat: 80,
    })

    const second = buildMonitorEcgPath({
      segmentWidth: 100,
      height: 30,
      beatsPerSegment: 2,
      segments: 2,
      samplesPerBeat: 80,
    })

    expect(first).toBe(second)
    expect(first.length).toBeGreaterThan(50)
  })

  it('starts and ends on the baseline', () => {
    const path = buildMonitorEcgPath({
      segmentWidth: 100,
      height: 30,
      beatsPerSegment: 2,
      segments: 2,
      samplesPerBeat: 80,
    })

    expect(path).toMatch(/^M\s*0\s*,\s*15(\s|,)/)
    expect(path).toContain('200,15')
  })
})
