Permalink
Browse files

Fix and add tests for ago()/before()/fromNow()/after().

  • Loading branch information...
1 parent 38cc6fc commit bbe5ed2d838e6b671f48b71a390c58f8f98e4f7b John Firebaugh committed May 21, 2010
Showing with 95 additions and 4 deletions.
  1. +2 −2 src/sugarpak.js
  2. +93 −2 test/sugarpak/index.js
View
@@ -32,7 +32,7 @@
$P._isSecond = false;
// private
- $N._dateElement = "day";
+ $N._dateElement = "days";
/**
* Moves the date to the next instance of a date as specified by the subsequent date element function (eg. .day(), .month()), month name function (eg. .january(), .jan()) or day name function (eg. .friday(), fri()).
@@ -445,7 +445,7 @@
$P[de] = $P[de + "s"] = ef(px[k]);
// Create date element functions and plural date element functions used with Number (eg. day(), days(), months()).
- $N[de] = $N[de + "s"] = nf(de);
+ $N[de] = $N[de + "s"] = nf(de + "s");
}
$P._ss = ef("Second");
@@ -9,8 +9,99 @@ Date.Specification = new Specification({
}
}
},
-
-
+
+ '.before()': {
+ setup: function() {},
+ 'seconds': {
+ run: function() { },
+ assert: function() {
+ return Date.equals((10).seconds().before(new Date(2010, 0, 1, 0, 0, 10)), new Date(2010, 0, 1));
+ }
+ },
+ 'minutes': {
+ run: function() { },
+ assert: function() {
+ return Date.equals((2).minutes().before(new Date(2010, 0, 1, 0, 2)), new Date(2010, 0, 1));
+ }
+ },
+ 'hours': {
+ run: function() { },
+ assert: function() {
+ return Date.equals((8).hours().before(new Date(2010, 0, 1, 8)), new Date(2010, 0, 1));
+ }
+ },
+ 'days': {
+ run: function() { },
+ assert: function() {
+ return Date.equals((4).days().before(new Date(2010, 0, 5)), new Date(2010, 0, 1));
+ }
+ },
+ 'weeks': {
+ run: function() { },
+ assert: function() {
+ return Date.equals((6).weeks().before(new Date(2010, 1, 12)), new Date(2010, 0, 1));
+ }
+ },
+ 'months': {
+ run: function() { },
+ assert: function() {
+ return Date.equals((12).months().before(new Date(2011, 0, 1)), new Date(2010, 0, 1));
+ }
+ },
+ 'years': {
+ run: function() { },
+ assert: function() {
+ return Date.equals((4).years().before(new Date(2014, 0, 1)), new Date(2010, 0, 1));
+ }
+ }
+ },
+
+ '.after()': {
+ setup: function() {},
+ 'seconds': {
+ run: function() { },
+ assert: function() {
+ return Date.equals((10).seconds().after(new Date(2010, 0, 1)), new Date(2010, 0, 1, 0, 0, 10));
+ }
+ },
+ 'minutes': {
+ run: function() { },
+ assert: function() {
+ return Date.equals((2).minutes().after(new Date(2010, 0, 1)), new Date(2010, 0, 1, 0, 2));
+ }
+ },
+ 'hours': {
+ run: function() { },
+ assert: function() {
+ return Date.equals((8).hours().after(new Date(2010, 0, 1)), new Date(2010, 0, 1, 8));
+ }
+ },
+ 'days': {
+ run: function() { },
+ assert: function() {
+ return Date.equals((4).days().after(new Date(2010, 0, 1)), new Date(2010, 0, 5));
+ }
+ },
+ 'weeks': {
+ run: function() { },
+ assert: function() {
+ return Date.equals((6).weeks().after(new Date(2010, 0, 1)), new Date(2010, 1, 12));
+ }
+ },
+ 'months': {
+ run: function() { },
+ assert: function() {
+ return Date.equals((12).months().after(new Date(2010, 0, 1)), new Date(2011, 0, 1));
+ }
+ },
+ 'years': {
+ run: function() { },
+ assert: function() {
+ return Date.equals((4).years().after(new Date(2010, 0, 1)), new Date(2014, 0, 1));
+ }
+ }
+ },
+
'.same()': {
setup: function() {},
'same year(Date.today())': {

0 comments on commit bbe5ed2

Please sign in to comment.