<?php

namespace Tests\Unit\Support;

use App\Support\CatalogThemeApplicator;
use App\Support\CatalogThemeRegistry;
use Tests\TestCase;

class CatalogThemeRegistryTest extends TestCase
{
    public function test_it_lists_themes_for_template_1(): void
    {
        $themes = CatalogThemeRegistry::forTemplate('template-1');

        $this->assertNotEmpty($themes);
        $this->assertTrue(CatalogThemeRegistry::isValidForTemplate('template-1', 'amazon'));
        $this->assertSame('Amazon', CatalogThemeRegistry::label('template-1', 'amazon'));
        $this->assertSame('amazon-theme', CatalogThemeRegistry::bodyClass('template-1', 'amazon'));
    }
}

class CatalogThemeApplicatorTest extends TestCase
{
    public function test_it_replaces_the_body_class(): void
    {
        $html = '<html><body class="problem-theme"><main>Hello</main></body></html>';

        $this->assertSame(
            '<html><body class="amazon-theme"><main>Hello</main></body></html>',
            CatalogThemeApplicator::apply($html, 'amazon-theme'),
        );
    }
}
