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