adrema/modules/Form/Components/PreventionSettingViewTest.php

41 lines
1.3 KiB
PHP

<?php
namespace Modules\Form\Components;
use App\Prevention\PreventionSettings;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Livewire\Livewire;
use Tests\RequestFactories\EditorRequestFactory;
use Tests\TestCase;
uses(TestCase::class);
uses(DatabaseTransactions::class);
it('it renders page', function () {
test()->withoutExceptionHandling()->login()->loginNami();
test()->get('/setting/prevention')->assertSeeLivewire(PreventionSettingView::class);
});
it('displays settings', function () {
test()->withoutExceptionHandling()->login()->loginNami();
$text = EditorRequestFactory::new()->text(50, 'lorem ipsum')->toData();
app(PreventionSettings::class)->fill(['formmail' => $text])->save();
Livewire::test(PreventionSettingView::class)
->assertSet('formmail.blocks.0.data.text', 'lorem ipsum')
->assertSeeHtml('data-active');
});
it('saves settings', function () {
test()->withoutExceptionHandling()->login()->loginNami();
$text = EditorRequestFactory::new()->text(50, 'new lorem')->create();
Livewire::test(PreventionSettingView::class)
->set('formmail', $text)
->call('save')
->assertDispatched('success', 'Einstellungen gespeichert.');
$this->assertTrue(app(PreventionSettings::class)->formmail->hasAll(['new lorem']));
});