Annotation of todotxt/Text-Todo-REST-API/t/formats/text.t, Revision 1.10
1.1 andrew 1: #===============================================================================
2: #
3: # FILE: text.t
4: #
1.10 ! andrew 5: # DESCRIPTION: Test Text::Todo::REST::API::Representations::text
1.1 andrew 6: #
7: # AUTHOR: Andrew Fresh (AAF), andrew@cpan.org
8: # COMPANY: Red River Communications
9: # CREATED: 01/07/10 19:11
1.10 ! andrew 10: # REVISION: $AFresh1: text.t,v 1.9 2010/01/19 03:18:34 andrew Exp $
1.1 andrew 11: #===============================================================================
12:
13: use strict;
14: use warnings;
15:
1.10 ! andrew 16: use Test::More tests => 19;
1.1 andrew 17:
18: my $class;
1.10 ! andrew 19: my $format;
1.1 andrew 20:
21: BEGIN {
1.10 ! andrew 22: $format = 'text';
! 23: $class = 'Text::Todo::REST::API::Representations::' . $format;
1.1 andrew 24: use_ok( $class, "use $class" );
25: }
26:
1.10 ! andrew 27: diag(
! 28: "Testing entry $class $Text::Todo::REST::API::Representations::text::VERSION"
! 29: );
1.1 andrew 30:
1.10 ! andrew 31: my $result;
! 32: my $api = new_ok($class);
1.5 andrew 33:
1.10 ! andrew 34: is( $api->content_type, 'text/plain', 'Check content_type' );
1.5 andrew 35:
1.10 ! andrew 36: my $files = ['todo.txt'];
! 37: my $files_render = join q{}, map "$_\n", @{$files};
1.5 andrew 38:
1.10 ! andrew 39: $result = undef;
! 40: ok( ($result) = $api->render_files( $format, $files ), 'render files' );
! 41: is_deeply( $result, $files_render, 'files render as expected' );
1.1 andrew 42:
1.10 ! andrew 43: my $list = [
1.1 andrew 44: { 'text' => '(A) entry 1 @one +uno',
45: 'md5' => '931e0831c31a70928b29de55778dc294',
46: 'line' => 1
47: },
48: { 'text' => 'entry 2 @two +dos',
49: 'md5' => 'b38dde8029c047e81379d9de581a6251',
50: 'line' => 2
51: },
52: { 'text' => '',
53: 'md5' => 'd41d8cd98f00b204e9800998ecf8427e',
54: 'line' => 3
55: },
56: { 'text' => 'x completed entry 4',
57: 'md5' => '8de0a2b65a50d5e30e84ad48af46fa78',
58: 'line' => 4
59: },
60: { 'text' => '(B) entry 5 is priority',
61: 'md5' => 'c1692dfbf3b5829b6bce44b1a1614980',
62: 'line' => 5
63: },
64: { 'text' => 'entry 6 +delete',
65: 'md5' => 'e1f6bf867f75aa019063782554407d02',
66: 'line' => 6
67: }
68: ];
69:
1.10 ! andrew 70: my $list_render = join q{}, map { $_->{text} . "\n" } @{$list};
1.1 andrew 71:
72: $result = undef;
1.10 ! andrew 73: ok( eval { $result = $api->render_list( $format, $list ) }, 'render_list' );
! 74: is( $result, $list_render, 'Got expected render_list result' );
1.3 andrew 75:
1.10 ! andrew 76: foreach my $e ( @{$list} ) {
1.3 andrew 77: my $result;
1.10 ! andrew 78: ok( eval { $result = $api->render_entry( $format, $e ) },
! 79: 'render_entry' );
! 80: is( $result, $e->{text} . "\n", 'Got correct render_entry result' );
1.2 andrew 81: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>