diff --git a/packages/tables/docs/12-testing.md b/packages/tables/docs/12-testing.md index 5024737623..434f287cb3 100644 --- a/packages/tables/docs/12-testing.md +++ b/packages/tables/docs/12-testing.md @@ -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: