Skip to content

Commit 2b1d63f

Browse files
Add tests for retrieving Inertia prop values and nested properties with dot notation
1 parent 0391cc7 commit 2b1d63f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/Testing/TestResponseMacrosTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,23 @@ public function test_it_can_retrieve_the_inertia_page(): void
5050
$this->assertFalse($page['clearHistory']);
5151
});
5252
}
53+
54+
public function test_it_can_retrieve_the_inertia_props(): void
55+
{
56+
$props = ['bar' => 'baz'];
57+
$response = $this->makeMockRequest(
58+
Inertia::render('foo', $props)
59+
);
60+
61+
tap($response->inertiaProps(), fn (array $pageProps) => $this->assertSame($props, $pageProps));
62+
}
63+
64+
public function test_it_can_retrieve_nested_inertia_prop_values_with_dot_notation(): void
65+
{
66+
$response = $this->makeMockRequest(
67+
Inertia::render('foo', ['bar' => ['baz' => 'qux']])
68+
);
69+
70+
tap($response->inertiaProps('bar.baz'), fn (mixed $value) => $this->assertSame('qux', $value));
71+
}
5372
}

0 commit comments

Comments
 (0)