separate request/response possible content-typees
[catagits/Catalyst-Action-REST.git] / t / jsonp.t
CommitLineData
d0d292d4 1use strict;
2use warnings;
3use Test::More;
4use FindBin;
5
6use lib ("$FindBin::Bin/lib", "$FindBin::Bin/../lib");
7use Test::Rest;
8use utf8;
9
10eval 'use JSON 2.12';
11plan skip_all => 'Install JSON 2.12 or later to run this test' if ($@);
12
d0d292d4 13
14use_ok 'Catalyst::Test', 'Test::Serialize', 'Catalyst::Action::Serialize::JSON';
15
16my $json = JSON->new->utf8;
17
18for ('text/javascript','application/x-javascript','application/javascript') {
19 my $t = Test::Rest->new('content_type' => $_);
20 my $monkey_template = { monkey => 'likes chicken!' };
21
22 my $mres = request($t->get(url => '/monkey_get?callback=omnivore'));
23 ok( $mres->is_success, 'GET the monkey succeeded' );
24
25 my ($json_param) = $mres->content =~ /^omnivore\((.*)?\);$/;
26 is_deeply($json->decode($json_param), $monkey_template, "GET returned the right data");
27}
28
291;
10018fb4 30
31done_testing;