forked from yuki-kimoto/gitprep
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added a test case for further refactoring purposes
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env perl | ||
|
||
use Test::More; | ||
|
||
use Gitprep::Git; | ||
|
||
my @cases = ( | ||
{ stimulus => 0, expected => ' right now' }, | ||
{ stimulus => 1, expected => 'a sec ago' }, | ||
{ stimulus => 59, expected => '59 sec ago' }, | ||
{ stimulus => 60, expected => 'a min ago' }, | ||
{ stimulus => 60 + 1, expected => 'a min ago' }, | ||
{ stimulus => 2 * 60 - 1, expected => 'a min ago' }, | ||
{ stimulus => 2 * 60, expected => '2 min ago' }, | ||
{ stimulus => 2 * 60 + 1, expected => '2 min ago' }, | ||
{ stimulus => 60 * 60 - 1, expected => '59 min ago' }, | ||
{ stimulus => 60 * 60, expected => 'a hours ago' }, | ||
{ stimulus => 60 * 60 + 1, expected => 'a hours ago' }, | ||
{ stimulus => 61 * 60, expected => 'a hours ago' }, | ||
{ stimulus => 24 * 60 * 60 - 1, expected => '23 hours ago' }, | ||
{ stimulus => 24 * 60 * 60, expected => 'a days ago' }, | ||
{ stimulus => 24 * 60 * 60 + 1, expected => 'a days ago' }, | ||
{ stimulus => 7 * 24 * 60 * 60 - 1, expected => '6 days ago' }, | ||
{ stimulus => 7 * 24 * 60 * 60, expected => 'a weeks ago' }, | ||
{ stimulus => 7 * 24 * 60 * 60 + 1, expected => 'a weeks ago' }, | ||
{ stimulus => (365/12) * 24 * 60 * 60 - 1, expected => '4 weeks ago' }, | ||
{ stimulus => (365/12) * 24 * 60 * 60, expected => 'a months ago' }, | ||
{ stimulus => (365/12) * 24 * 60 * 60 + 1, expected => 'a months ago' }, | ||
{ stimulus => 365 * 24 * 60 * 60 - 1, expected => '11 months ago' }, | ||
{ stimulus => 365 * 24 * 60 * 60, expected => 'a years ago' }, | ||
{ stimulus => 365 * 24 * 60 * 60 + 1, expected => 'a years ago' }, | ||
); | ||
|
||
plan ( tests => scalar @cases ); | ||
|
||
for ( @cases ) { | ||
is ( Gitprep::Git->_age_string ( $_->{stimulus} ), $_->{expected}, "$_->{stimulus} ~ $_->{expected}" ); | ||
} |