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