# 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 'async' do
  it 'async_extract_bytes: Async extract_bytes call on PDF document' do
    content = File.read("pdf/fake_memo.pdf").bytes
    result = Kreuzberg.extract_bytes_async(content, 'application/pdf')
    expect(result.mime_type.to_s.strip).to eq('application/pdf'.strip)
    expect(result.content.length).to be >= 50

  end

  it 'async_extract_bytes_empty_mime: extract_bytes empty MIME async' do
    expect {
      content = File.read("text/plain.txt").bytes
      Kreuzberg.extract_bytes_async(content, '', Kreuzberg::ExtractionConfig.new())
    }.to raise_error(RuntimeError)
  end

  it 'async_extract_bytes_invalid_mime: extract_bytes unsupported MIME async' do
    expect {
      content = File.read("text/plain.txt").bytes
      Kreuzberg.extract_bytes_async(content, 'application/x-nonexistent', Kreuzberg::ExtractionConfig.new())
    }.to raise_error(RuntimeError)
  end
end
