Skip to content

Commit 7a297d8

Browse files
committed
use view data on ResponseTest
1 parent e6c3775 commit 7a297d8

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

tests/ResponseTest.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Inertia\Tests;
44

55
use Inertia\Response;
6+
use Illuminate\View\View;
67
use Illuminate\Http\Request;
78
use Illuminate\Http\JsonResponse;
89
use Illuminate\Http\Response as BaseResponse;
@@ -21,9 +22,17 @@ public function test_server_response()
2122
);
2223

2324
$response = $response->toResponse($request);
25+
$view = $response->getOriginalContent();
26+
$page = $view->getData()['page'];
2427

2528
$this->assertInstanceOf(BaseResponse::class, $response);
26-
$this->assertSame('<div id="app" data-page="{&quot;component&quot;:&quot;User\/Edit&quot;,&quot;props&quot;:{&quot;user&quot;:{&quot;name&quot;:&quot;Jonathan&quot;}},&quot;url&quot;:&quot;\/user\/123&quot;,&quot;version&quot;:&quot;123&quot;}"></div>'."\n", $response->content());
29+
$this->assertInstanceOf(View::class, $view);
30+
31+
$this->assertSame('User/Edit', $page['component']);
32+
$this->assertSame('Jonathan', $page['props']['user']['name']);
33+
$this->assertSame('/user/123', $page['url']);
34+
$this->assertSame('123', $page['version']);
35+
$this->assertSame('<div id="app" data-page="{&quot;component&quot;:&quot;User\/Edit&quot;,&quot;props&quot;:{&quot;user&quot;:{&quot;name&quot;:&quot;Jonathan&quot;}},&quot;url&quot;:&quot;\/user\/123&quot;,&quot;version&quot;:&quot;123&quot;}"></div>'."\n", $view->render());
2736
}
2837

2938
public function test_xhr_response()

0 commit comments

Comments
 (0)