# 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 'error' do
  it 'error_empty_bytes: Graceful handling of empty bytes (should not error)' do
    content = File.read("text/empty.txt").bytes
    result = Kreuzberg.extract_bytes_sync(content, 'text/plain', Kreuzberg::ExtractionConfig.new())

    expect(result).not_to be_nil
  end

  it 'error_empty_mime: Error when extracting with empty MIME type' do
    expect {
      content = File.read("text/plain.txt").bytes
      Kreuzberg.extract_bytes_sync(content, '', Kreuzberg::ExtractionConfig.new())
    }.to raise_error(RuntimeError)
  end

  it 'error_extract_bytes_conflicting_ocr: extract_bytes force+disable OCR' do
    expect {
      content = File.read("text/fake_text.txt").bytes
      Kreuzberg.extract_bytes_sync(content, 'text/plain', Kreuzberg::ExtractionConfig.new(disable_ocr: true, force_ocr: true))
    }.to raise_error(RuntimeError)
  end

  it 'error_invalid_mime_format: Error when extracting with invalid MIME type format' do
    expect {
      content = File.read("text/plain.txt").bytes
      Kreuzberg.extract_bytes_sync(content, 'not-a-mime', Kreuzberg::ExtractionConfig.new())
    }.to raise_error(RuntimeError)
  end

  it 'error_unsupported_mime: Error when extracting with unsupported MIME type' do
    expect {
      content = File.read("text/plain.txt").bytes
      Kreuzberg.extract_bytes_sync(content, 'application/x-nonexistent', Kreuzberg::ExtractionConfig.new())
    }.to raise_error(RuntimeError)
  end
end
