aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDaniel Perez Alvarez <[email protected]>2014-11-12 08:43:23 +0000
committerDaniel Perez Alvarez <[email protected]>2014-11-12 08:43:23 +0000
commitba482f10bed1a4e34cf1941bb5728d0a029822a4 (patch)
tree8ee41919fd2bad1348f95c64b2dd7a91e1617221 /test
parentc109b4873aa794965d37bda10dbacc51e2073bc8 (diff)
downloadfaker-ba482f10bed1a4e34cf1941bb5728d0a029822a4.tar.xz
faker-ba482f10bed1a4e34cf1941bb5728d0a029822a4.zip
Have past, future and recent return random dates
Functions `past` and `future` only returned dates EXACTLY N YEARS before or after the reference date. Function `recent` only returned dates EXACTLY N DAYS before the reference date. For example, `faker.date.past(1)` would return either *Nov 12, 2014*, or *Nov 12, 2013*, but nothing in-between. Also, now you can call those functions without parameter, and N will take the default value of `1`.
Diffstat (limited to 'test')
-rw-r--r--test/date.unit.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/test/date.unit.js b/test/date.unit.js
index b15e2043..cc0cddc7 100644
--- a/test/date.unit.js
+++ b/test/date.unit.js
@@ -12,6 +12,14 @@ describe("date.js", function () {
assert.ok(date < new Date());
});
+ it("returns a past date when N = 0", function () {
+
+ var refDate = new Date();
+ var date = faker.date.past(0, refDate.toJSON());
+
+ assert.ok(date < refDate); // date should be before the date given
+ });
+
it("returns a date N years before the date given", function () {
var refDate = new Date(2120, 11, 9, 10, 0, 0, 0); // set the date beyond the usual calculation (to make sure this is working correctly)
@@ -36,7 +44,7 @@ describe("date.js", function () {
var refDate = new Date();
var date = faker.date.future(0, refDate.toJSON());
- assert.ok(date > refDate); // date should be after the date given, but before the current time
+ assert.ok(date > refDate); // date should be after the date given
});
it("returns a date N years after the date given", function () {