summary refs log tree commit diff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/spore-middleware/format-json.t17
1 files changed, 16 insertions, 1 deletions
diff --git a/t/spore-middleware/format-json.t b/t/spore-middleware/format-json.t
index 95d84c3..20dd1e9 100644
--- a/t/spore-middleware/format-json.t
+++ b/t/spore-middleware/format-json.t
@@ -7,14 +7,26 @@ use JSON;
 use Net::HTTP::Spore;
 
 my $content = { keys => [qw/1 2 3/] };
+my $payload = {user => 'foo'};
 
 my $mock_server = {
     '/show' => sub {
         my $req = shift;
+        is( $req->header('Accept'), 'application/json' );
         $req->new_response(
             200,
             [ 'Content-Type' => 'application/json' ],
-            JSON::encode_json( $content )
+            JSON::encode_json($content)
+        );
+    },
+    '/add' => sub {
+        my $req = shift;
+        is( $req->header('Content-Type'), 'application/json;' );
+        is_deeply( JSON::decode_json( $req->body ), $payload );
+        $req->new_response(
+            200,
+            [ 'Content-Type' => 'application/json' ],
+            JSON::encode_json($content)
         );
     },
 };
@@ -34,4 +46,7 @@ is $res->header('Content-Type'), 'application/json';
 my $req = $res->request;
 is $req->header('Accept'), 'application/json';
 
+$res = $client->add_user(payload => $payload);
+is $res->[0], 200;
+
 done_testing;