<?php

namespace Tests\Unit\Services\Frontend;

use App\Services\Frontend\StaticPageService;
use Illuminate\Support\Facades\File;
use Tests\TestCase;

class StaticPageServiceTest extends TestCase
{
    public function test_load_returns_content(): void
    {
        $dir = public_path('html');
        File::ensureDirectoryExists($dir);
        File::put($dir . '/terms_of_service.html', '<h1>Terms</h1>');

        $service = new StaticPageService();
        $result = $service->load('terms_of_service.html', 'terms_of_service');

        $this->assertTrue($result['ok']);
        $this->assertSame('terms_of_service', $result['type']);
        $this->assertStringContainsString('Terms', $result['content']);
    }

    public function test_load_missing_returns_error(): void
    {
        $service = new StaticPageService();
        $result = $service->load('missing.html', 'missing');

        $this->assertFalse($result['ok']);
    }
}
