<?php

use App\Enums\IsActive;
use App\Models\Department;
use Illuminate\Foundation\Testing\RefreshDatabase;

uses(RefreshDatabase::class);

describe('Department Model', function () {
    it('can create a department', function () {
        $department = Department::factory()->create([
            'name' => 'Test Department',
            'alias' => 'TESTDEPT',
        ]);

        expect($department->name)->toBe('Test Department')
            ->and($department->alias)->toBe('TESTDEPT')
            ->and($department->exists)->toBeTrue();
    });

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

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

    it('casts is_active to enum', function () {
        $department = Department::factory()->create(['is_active' => IsActive::ACTIVE]);

        expect($department->is_active)->toBeInstanceOf(IsActive::class)
            ->and($department->is_active)->toBe(IsActive::ACTIVE);
    });
});
