Permalink
Browse files

sequential dates!

  • Loading branch information...
aaronpowell committed Dec 4, 2011
1 parent 6f3a9ce commit 502358fcd0b635fd2c0ae7b171d8403453fc718f
Showing with 24 additions and 0 deletions.
  1. +14 −0 lib/tbd.js
  2. +10 −0 tests/until-sequential-spec.js
View
@@ -155,6 +155,20 @@
return start + letters[index++];
};
}
+ } else if (start.constructor === Date) {
+ var dateType = arguments[1] || 'd',
+ inc = 0;
+ return function () {
+ start = new Date(start.getFullYear(), start.getMonth(), start.getDate(), start.getHours(), start.getMinutes(), start.getSeconds(), start.getMilliseconds());
+ switch(dateType) {
+ case 'd':
+ start.setDate(start.getDate() + inc++);
+ break;
+ default:
+ throw 'The value ' + dateType + ' is not an understood date part';
+ }
+ return start;
+ };
} else {
throw 'This type is not supported for sequential values at the moment';
}
@@ -36,4 +36,14 @@ describe('tbd-util-sequantial', function() {
expect(data[0].foo).toBe('z');
expect(data[1].foo).toBe('a');
});
+
+ it('should handle sequential dates', function () {
+ var start = new Date(),
+ data = tbd.from({})
+ .prop('foo').use(tbd.utils.sequential(start))
+ .make(2);
+
+ expect(data[0].foo).toEqual(start);
+ expect(data[1].foo).not.toEqual(start);
+ });
});

0 comments on commit 502358f

Please sign in to comment.