From cc9ba73cdd6e17495a263c874c22d0d7592be6d2 Mon Sep 17 00:00:00 2001 From: franck cuny Date: Wed, 24 Nov 2010 11:18:53 +0100 Subject: add new tests to check content-type value --- t/spore-middleware/format-json.t | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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; -- cgit v1.2.3