[BACK]Return to entry.t CVS log [TXT][DIR] Up to [local] / todotxt / Text-Todo / t

Annotation of todotxt/Text-Todo/t/entry.t, Revision 1.3

1.1       andrew      1: #===============================================================================
                      2: #
                      3: #         FILE:  20.entry.t
                      4: #
                      5: #  DESCRIPTION:  Test an entry that we create
                      6: #
                      7: #       AUTHOR:  Andrew Fresh (AAF), andrew@cpan.org
                      8: #      COMPANY:  Red River Communications
                      9: #      CREATED:  07/10/09 11:32:39
1.3     ! andrew     10: #     REVISION:  $RedRiver: 20.entry.t,v 1.2 2009/07/11 15:58:13 andrew Exp $
1.1       andrew     11: #===============================================================================
                     12:
                     13: use strict;
                     14: use warnings;
                     15:
                     16: use Test::More tests => 29;    # last test to print
                     17:
                     18: my $class = 'Text::Todo::Entry';
                     19:
                     20: BEGIN: { use_ok( $class, "use $class" ) }
                     21:
                     22: diag("Testing 20 entry $class $Text::Todo::Entry::VERSION");
                     23:
                     24: my $e = new_ok($class);
                     25:
                     26: is( $e->text,     '',    "Make sure entry is blank" );
                     27: is( $e->priority, undef, "check priority is undef" );
                     28: is_deeply( [ $e->contexts ], [], "check contexts are empty" );
                     29: is_deeply( [ $e->projects ], [], "check projects are empty" );
                     30:
                     31: my %sample = (
1.3     ! andrew     32:     text => '(B) @home @work send email to andrew@cpan.org +say_thanks',
1.1       andrew     33:     priority    => 'B',
                     34:     contexts    => [ 'home', 'work' ],
1.3     ! andrew     35:     projects    => ['say_thanks'],
1.1       andrew     36:     prepend     => 'before',
                     37:     append      => 'or something',
                     38:     new_project => 'notnapping',
                     39:     new_context => 'car',
                     40: );
                     41:
                     42: ok( $e->change( $sample{text} ), 'Update entry' );
                     43: is( $e->text,     $sample{text},     "Make sure entry matches" );
                     44: is( $e->priority, $sample{priority}, "check priority" );
                     45: is_deeply( [ $e->contexts ], $sample{contexts}, "check contexts" );
                     46: is_deeply( [ $e->projects ], $sample{projects}, "check projects" );
                     47:
                     48: $sample{text} =~ s/^( \s* \( $sample{priority} \))/$1 $sample{prepend}/xms;
1.2       andrew     49: ok( $e->prepend( $sample{prepend} ), 'Prepend entry' );
1.1       andrew     50: is( $e->text,     $sample{text},     "Make sure entry matches" );
                     51: is( $e->priority, $sample{priority}, "check priority" );
                     52: is_deeply( [ $e->contexts ], $sample{contexts}, "check contexts" );
                     53: is_deeply( [ $e->projects ], $sample{projects}, "check projects" );
                     54:
                     55: $sample{text} .= ' ' . $sample{append};
1.2       andrew     56: ok( $e->append( $sample{append} ), 'Append entry' );
1.1       andrew     57: is( $e->text,     $sample{text},     "Make sure entry matches" );
                     58: is( $e->priority, $sample{priority}, "check priority" );
                     59: is_deeply( [ $e->contexts ], $sample{contexts}, "check contexts" );
                     60: is_deeply( [ $e->projects ], $sample{projects}, "check projects" );
                     61:
                     62: ok( !$e->in_project( $sample{new_project} ), 'not in new project yet' );
                     63: push @{ $sample{projects} }, $sample{new_project};
                     64: $sample{text} .= ' +' . $sample{new_project};
1.2       andrew     65: ok( $e->append( '+' . $sample{new_project} ), 'Add project' );
1.1       andrew     66: is( $e->text, $sample{text}, "Make sure entry matches" );
                     67: ok( $e->in_project( $sample{new_project} ), 'now in new project' );
                     68:
                     69: ok( !$e->in_context( $sample{new_context} ), 'not in new context yet' );
                     70: push @{ $sample{contexts} }, $sample{new_context};
                     71: $sample{text} .= ' @' . $sample{new_context};
1.2       andrew     72: ok( $e->append( '@' . $sample{new_context} ), 'Add context' );
1.1       andrew     73: is( $e->text, $sample{text}, "Make sure entry matches" );
                     74: ok( $e->in_context( $sample{new_context} ), 'now in new context' );

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>