updated docs

This commit is contained in:
chester
2024-12-13 10:56:28 +08:00
parent 1c2657d7f2
commit 47a07218ff
+22
View File
@@ -489,6 +489,28 @@ it('can load existing post data for editing', function () {
});
```
You may also find it useful to pass a function to the `assertTableActionDataSet()` and `assertTableBulkActionDataSet()` method, which allows you to access the form `$state` and perform additional assertions:
```php
use Illuminate\Support\Str;
use function Pest\Livewire\livewire;
it('can automatically generate a slug from the title without any spaces', function () {
$post = Post::factory()->create();
livewire(PostResource\Pages\ListPosts::class)
->mountTableAction(EditAction::class, $post)
->assertTableActionDataSet(function (array $state) use($post): array {
expect($state['slug'])
->not->toContain(' ');
return [
'slug' => Str::slug($post->title),
];
});
});
```
### Action state
To ensure that an action or bulk action exists or doesn't in a table, you can use the `assertTableActionExists()` / `assertTableActionDoesNotExist()` or `assertTableBulkActionExists()` / `assertTableBulkActionDoesNotExist()` method: