Skip to content

Commit

Permalink
Add tests for Posts#recent and Posts#by_date
Browse files Browse the repository at this point in the history
  • Loading branch information
evilstreak committed Jan 26, 2010
1 parent a7de80d commit 34b1b94
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/models.t.js
Expand Up @@ -85,6 +85,29 @@ exports.tests.test_Posts = {
// unpublished
asserts.same( Posts.by_tags( [ "gamma" ] ), [], "Doesn't return future posts" );
asserts.same( Posts.by_tags( [ "delta" ] ), [], "Doesn't return draft posts" );
},

test_recent : function() {
setup( [] );
asserts.same( Posts.recent(), [], "Returns an empty array if no posts exist" );

setup( [ f, g ] );
asserts.same( Posts.recent(), [], "Returns an empty array if only unpublished posts exist" );

setup( [ a, b, c ] );
asserts.same( Posts.recent(), [ c, b, a ], "Returns posts by published order" );
},

test_by_date : function() {
setup( [ h, i, j, k, l ] );
// just a year
asserts.same( Posts.by_date( 1999 ), [], "Returns no posts for 1999" );
asserts.same( Posts.by_date( 2000 ), [ k, j, i, h ], "Returns 4 (ordered) posts for 2000" );
asserts.same( Posts.by_date( 2001 ), [ l ], "Returns 1 post for 2001" );

asserts.same( Posts.by_date( 2000, 8 ), [], "Returns no posts for August 2000" );
asserts.same( Posts.by_date( 2000, 9 ), [ i, h ], "Returns 2 posts for September 2000" );
asserts.same( Posts.by_date( 2000, 10 ), [ k, j ], "Returns 2 posts for October 2000" );
}
}

Expand Down

0 comments on commit 34b1b94

Please sign in to comment.