@@ -63,6 +63,21 @@ public function test_inertia_directive_renders_the_root_element(): void
6363 $ this ->assertSame ($ html , $ this ->renderView ("@inertia('') " , ['page ' => self ::EXAMPLE_PAGE_OBJECT ]));
6464 }
6565
66+ public function test_inertia_directive_renders_the_root_element_and_script_element (): void
67+ {
68+ Config::set ([
69+ 'inertia.ssr.enabled ' => false ,
70+ 'inertia.use_script_element_for_initial_page ' => true ,
71+ ]);
72+
73+ $ html = '<script data-page="app" type="application/json">{"component":"Foo\/Bar","props":{"foo":"bar"},"url":"\/test","version":"","encryptHistory":false,"clearHistory":false}</script><div id="app"></div> ' ;
74+
75+ $ this ->assertSame ($ html , $ this ->renderView ('@inertia ' , ['page ' => self ::EXAMPLE_PAGE_OBJECT ]));
76+ $ this ->assertSame ($ html , $ this ->renderView ('@inertia() ' , ['page ' => self ::EXAMPLE_PAGE_OBJECT ]));
77+ $ this ->assertSame ($ html , $ this ->renderView ('@inertia("") ' , ['page ' => self ::EXAMPLE_PAGE_OBJECT ]));
78+ $ this ->assertSame ($ html , $ this ->renderView ("@inertia('') " , ['page ' => self ::EXAMPLE_PAGE_OBJECT ]));
79+ }
80+
6681 public function test_inertia_directive_renders_server_side_rendered_content_when_enabled (): void
6782 {
6883 Config::set (['inertia.ssr.enabled ' => true ]);
@@ -84,6 +99,20 @@ public function test_inertia_directive_can_use_a_different_root_element_id(): vo
8499 $ this ->assertSame ($ html , $ this ->renderView ('@inertia("foo") ' , ['page ' => self ::EXAMPLE_PAGE_OBJECT ]));
85100 }
86101
102+ public function test_inertia_directive_can_use_a_different_root_element_id_when_using_script_element (): void
103+ {
104+ Config::set ([
105+ 'inertia.ssr.enabled ' => false ,
106+ 'inertia.use_script_element_for_initial_page ' => true ,
107+ ]);
108+
109+ $ html = '<script data-page="foo" type="application/json">{"component":"Foo\/Bar","props":{"foo":"bar"},"url":"\/test","version":"","encryptHistory":false,"clearHistory":false}</script><div id="foo"></div> ' ;
110+
111+ $ this ->assertSame ($ html , $ this ->renderView ('@inertia(foo) ' , ['page ' => self ::EXAMPLE_PAGE_OBJECT ]));
112+ $ this ->assertSame ($ html , $ this ->renderView ("@inertia('foo') " , ['page ' => self ::EXAMPLE_PAGE_OBJECT ]));
113+ $ this ->assertSame ($ html , $ this ->renderView ('@inertia("foo") ' , ['page ' => self ::EXAMPLE_PAGE_OBJECT ]));
114+ }
115+
87116 public function test_inertia_head_directive_renders_nothing (): void
88117 {
89118 Config::set (['inertia.ssr.enabled ' => false ]);
0 commit comments