<?php

namespace Tests\Feature\Membership;

use App\Member\Member;
use App\Member\Membership;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Livewire\Livewire;
use Modules\Member\TestersBlock;
use Tests\TestCase;

class TestersBlockTest extends TestCase
{
    use DatabaseTransactions;

    public function testItHasData(): void
    {
        $this->login()->loginNami();

        Member::factory()
            ->defaults()
            ->has(Membership::factory()->in('Schnuppermitgliedschaft', 7, 'Wölfling', 8)->state(['from' => now()->subMonths(10)]))
            ->create(['firstname' => 'Max', 'lastname' => 'Muster']);
        Member::factory()
            ->defaults()
            ->has(Membership::factory()->ended()->in('Schnuppermitgliedschaft', 7, 'Wölfling', 8)->state(['from' => now()->subMonths(10)]))
            ->create(['firstname' => 'Jane', 'lastname' => 'Muster']);

        Livewire::test(TestersBlock::class)
            ->assertSee('Max Muster')
            ->assertSee(now()->subMonths(10)->addWeeks(8)->format('d.m.Y'))
            ->assertSee(now()->subMonths(10)->addWeeks(8)->diffForHumans())
            ->assertDontSee('Jane');
    }
}
