<?php

namespace Tests\Unit\Resources\Notifications;

use App\Http\Resources\Notifications\NotificationResource;
use App\Models\Notification;
use Tests\TestCase;

class NotificationResourceTest extends TestCase
{
    public function test_resource_returns_expected_shape(): void
    {
        $notification = new Notification([
            'id' => 1,
            'title' => 'Title',
            'message' => 'Message',
            'target_group' => 'parent',
            'delivery_channels' => ['in_app'],
            'priority' => 'normal',
            'status' => 'sent',
            'action_url' => 'https://example.test',
            'attachment_path' => '/path/file.pdf',
            'scheduled_at' => now(),
            'sent_at' => now(),
            'expires_at' => now()->addDay(),
            'school_year' => '2025-2026',
            'semester' => 'Fall',
            'created_at' => now(),
            'updated_at' => now(),
        ]);

        $payload = (new NotificationResource($notification))->toArray(request());

        $this->assertArrayHasKey('id', $payload);
        $this->assertArrayHasKey('title', $payload);
        $this->assertArrayHasKey('message', $payload);
        $this->assertArrayHasKey('target_group', $payload);
        $this->assertArrayHasKey('delivery_channels', $payload);
        $this->assertArrayHasKey('priority', $payload);
        $this->assertArrayHasKey('status', $payload);
        $this->assertArrayHasKey('action_url', $payload);
        $this->assertArrayHasKey('attachment_path', $payload);
        $this->assertArrayHasKey('scheduled_at', $payload);
        $this->assertArrayHasKey('sent_at', $payload);
        $this->assertArrayHasKey('expires_at', $payload);
        $this->assertArrayHasKey('school_year', $payload);
        $this->assertArrayHasKey('semester', $payload);
        $this->assertArrayHasKey('created_at', $payload);
        $this->assertArrayHasKey('updated_at', $payload);
    }
}
