import { describe, expect, it, vi } from 'vitest'
import { putObject } from './r2-binding'

describe('@platform-modules/uploads/r2-binding', () => {
  it('calls bucket.put with the exact key and options', async () => {
    const put = vi.fn(async () => ({ key: 'a/b.txt', size: 3, etag: 'etag-1' }))
    const bucket = { put }

    const body = new Uint8Array([1, 2, 3])
    const opts = { httpMetadata: { contentType: 'text/plain' }, customMetadata: { source: 'harness' } }
    const result = await putObject(bucket, 'a/b.txt', body, opts)

    expect(put).toHaveBeenCalledWith('a/b.txt', body, opts)
    expect(result.etag).toBe('etag-1')
  })
})
