# This file is auto-generated by alef — DO NOT EDIT.
# alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75
# To regenerate: alef generate
# To verify freshness: alef verify --exit-code
# Issues & docs: https://github.com/kreuzberg-dev/alef
# frozen_string_literal: true

require 'kreuzberg'
require 'json'
require 'spec_helper'

RSpec.describe 'batch' do
  it 'batch_bytes_invalid_mime: batch_extract_bytes_sync invalid MIME' do
    result = Kreuzberg.batch_extract_bytes_sync([Kreuzberg::BatchBytesItem.new(content: [72, 101, 108, 108, 111], mime_type: "application/x-nonexistent", config: nil)])

    expect(result).not_to be_nil
  end

  it 'batch_extract_bytes_happy: batch_extract_bytes: happy path with mixed inputs' do
    result = Kreuzberg.batch_extract_bytes_async([Kreuzberg::BatchBytesItem.new(content: [72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33], mime_type: "text/plain", config: nil), Kreuzberg::BatchBytesItem.new(content: [60, 104, 116, 109, 108, 62, 60, 98, 111, 100, 121, 62, 84, 101, 115, 116, 60, 47, 98, 111, 100, 121, 62, 60, 47, 104, 116, 109, 108, 62], mime_type: "text/html", config: nil)])
    expect(result.length).to be >= 1

  end

  it 'batch_extract_bytes_mixed_format: batch_extract_bytes: handles unsupported MIME gracefully' do
    result = Kreuzberg.batch_extract_bytes_async([Kreuzberg::BatchBytesItem.new(content: [80, 68, 70, 32, 112, 108, 97, 99, 101, 104, 111, 108, 100, 101, 114], mime_type: "application/x-unknown", config: nil)])

    expect(result).not_to be_nil
  end

  it 'batch_extract_bytes_sync_empty_list: batch_extract_bytes_sync: empty batch' do
    result = Kreuzberg.batch_extract_bytes_sync([])
    expect(result.length).to eq(0)

  end

  it 'batch_extract_bytes_sync_invalid_mime: batch_extract_bytes_sync: unsupported MIME' do
    result = Kreuzberg.batch_extract_bytes_sync([Kreuzberg::BatchBytesItem.new(content: [100, 97, 116, 97], mime_type: "application/x-unknown", config: nil)])

    expect(result).not_to be_nil
  end

  it 'batch_file_async_basic: Extract text from multiple files asynchronously' do
    result = Kreuzberg.batch_extract_files_async([Kreuzberg::BatchFileItem.new(path: "pdf/fake_memo.pdf", config: nil), Kreuzberg::BatchFileItem.new(path: "text/fake_text.txt", config: nil)])

    expect(result).not_to be_nil
  end

  it 'batch_file_async_not_found: batch_extract_file async nonexistent' do
    result = Kreuzberg.batch_extract_files_async([Kreuzberg::BatchFileItem.new(path: "/nonexistent/a.pdf", config: nil)])

    expect(result).not_to be_nil
  end

  it 'batch_file_not_found: batch_extract_file_sync nonexistent' do
    result = Kreuzberg.batch_extract_files_sync([Kreuzberg::BatchFileItem.new(path: "/nonexistent/a.pdf", config: nil), Kreuzberg::BatchFileItem.new(path: "/nonexistent/b.txt", config: nil)])

    expect(result).not_to be_nil
  end

  it 'batch_file_partial: batch_extract_file_sync mixed' do
    result = Kreuzberg.batch_extract_files_sync([Kreuzberg::BatchFileItem.new(path: "text/plain.txt", config: nil), Kreuzberg::BatchFileItem.new(path: "/nonexistent/missing.pdf", config: nil)])

    expect(result).not_to be_nil
  end

  it 'batch_file_sync_basic: Extract text from multiple files synchronously' do
    result = Kreuzberg.batch_extract_files_sync([Kreuzberg::BatchFileItem.new(path: "pdf/fake_memo.pdf", config: nil), Kreuzberg::BatchFileItem.new(path: "text/fake_text.txt", config: nil)])

    expect(result).not_to be_nil
  end
end
