add tests for view of object and for 404
[catagits/catbook-code.git] / t / controller_Translate.t
1 use strict;
2 use warnings;
3 use Test::More qw/no_plan/;
4
5 BEGIN { use_ok 'Catalyst::Test', 'LolCatalyst::Lite' }
6
7 use HTTP::Request::Common;
8
9 my ($request, $response);
10
11 $request = POST(
12         'http://localhost/translate',
13         'Content-Type' => 'form-data',
14         'Content'      => [
15             'lol' => 'Can i have a cheese burger?',
16         ]);
17
18 ok( $response = request($request), 'Request');
19 ok( $response->is_success, 'Response Successful 2xx' );
20 is( $response->content_type, 'text/html', 'Response Content-Type' );
21 like( $response->content, qr/CHEEZ/, "contains translated string");
22
23 ok(
24   $response = request(GET 'http://localhost/translate/1'),
25   'Request for default translation type'
26 );
27
28 ok( $response->is_success, 'Response Successful 2xx' );
29
30 like( $response->content, qr/CHEEZ/, "contains translated string");
31
32 ok(
33   $response = request(GET 'http://localhost/translate/100'),
34   'Request for default translation type on non-existant object'
35 );
36
37 cmp_ok( $response->code, '==', 404, '404 error returned');
38
39 ok(
40   $response = request(GET 'http://localhost/translate/1/to/LOLCAT'),
41   'Request for specific translation type'
42 );
43
44 ok( $response->is_success, 'Response Successful 2xx' );
45
46 like( $response->content, qr/CHEEZ/, "contains translated string");