Fix a typoe comment
[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
13plan tests => 7;
14
15use_ok 'Catalyst::Test', 'Test::Serialize', 'Catalyst::Action::Serialize::JSON';
16
17my $json = JSON->new->utf8;
18
19for ('text/javascript','application/x-javascript','application/javascript') {
20 my $t = Test::Rest->new('content_type' => $_);
21 my $monkey_template = { monkey => 'likes chicken!' };
22
23 my $mres = request($t->get(url => '/monkey_get?callback=omnivore'));
24 ok( $mres->is_success, 'GET the monkey succeeded' );
25
26 my ($json_param) = $mres->content =~ /^omnivore\((.*)?\);$/;
27 is_deeply($json->decode($json_param), $monkey_template, "GET returned the right data");
28}
29
301;