<?php

use App\Enums\MediaClassification;
use App\Enums\MediaType;
use App\Models\PartnerMedia;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Foundation\Testing\RefreshDatabase;

uses(RefreshDatabase::class);

describe('PartnerMedia Model', function () {
    it('can create a partner media', function () {
        $partner = PartnerMedia::factory()->create([
            'name' => 'Test Partner',
        ]);

        expect($partner->name)->toBe('Test Partner')
            ->and($partner->exists)->toBeTrue();
    });

    it('has guarded attributes', function () {
        $guarded = ['id'];

        expect(PartnerMedia::make()->getGuarded())->toEqual($guarded);
    });

    it('belongs to company', function () {
        $partner = PartnerMedia::factory()->create();

        expect($partner->company())->toBeInstanceOf(BelongsTo::class);
    });

    it('casts type to media type enum', function () {
        $partner = PartnerMedia::factory()->create(['type' => MediaType::ONLINE]);

        expect($partner->type)->toBeInstanceOf(MediaType::class)
            ->and($partner->type)->toBe(MediaType::ONLINE);
    });

    it('casts classification to media classification enum', function () {
        $partner = PartnerMedia::factory()->create(['classification' => MediaClassification::NATIONAL]);

        expect($partner->classification)->toBeInstanceOf(MediaClassification::class)
            ->and($partner->classification)->toBe(MediaClassification::NATIONAL);
    });
});
