Files
many-notes/tests/Feature/Vault/RowTest.php
2025-02-02 18:31:58 +00:00

28 lines
782 B
PHP

<?php
declare(strict_types=1);
use App\Actions\CreateVault;
use App\Actions\GetPathFromUser;
use App\Livewire\Vault\Row;
use App\Models\User;
use Livewire\Livewire;
it('updates the vault', function (): void {
$user = User::factory()->create()->first();
$vault = new CreateVault()->handle($user, [
'name' => fake()->words(3, true),
]);
$newName = fake()->words(3, true);
Livewire::actingAs($user)
->test(Row::class, ['vault' => $vault])
->set('form.name', $newName)
->call('update');
expect($user->vaults()->first()->name)->toBe($newName);
$relativePath = new GetPathFromUser()->handle($user);
$absolutePath = Storage::disk('local')->path($relativePath . $newName);
expect($absolutePath)->toBeDirectory();
});