<?php

use Datalumo\PhpSdk\DataObjects\StreamResponse;
use Datalumo\PhpSdk\HttpClient;
use Datalumo\PhpSdk\Resources\IntegrationResource;

beforeEach(function () {
    $this->http = Mockery::mock(HttpClient::class);
    $this->resource = new IntegrationResource($this->http);
});

it('streams summarise with stream=true', function () {
    $streamResponse = Mockery::mock(StreamResponse::class);

    $this->http->shouldReceive('getStream')
        ->with('integrations/int-1/summarise', ['query' => 'test', 'stream' => true])
        ->once()
        ->andReturn($streamResponse);

    $result = $this->resource->streamSummarise('int-1', ['query' => 'test']);

    expect($result)->toBe($streamResponse);
});

it('streams chat with stream=true', function () {
    $streamResponse = Mockery::mock(StreamResponse::class);

    $this->http->shouldReceive('postStream')
        ->with('integrations/int-1/chat', ['message' => 'hello', 'stream' => true])
        ->once()
        ->andReturn($streamResponse);

    $result = $this->resource->streamChat('int-1', ['message' => 'hello']);

    expect($result)->toBe($streamResponse);
});
