diff options
| author | Ronen Babayoff <[email protected]> | 2015-08-23 21:57:46 -0400 |
|---|---|---|
| committer | Ronen Babayoff <[email protected]> | 2015-08-23 21:57:46 -0400 |
| commit | 66996e280c9fbbbc2e7db376549f568be32ad5cd (patch) | |
| tree | e93f412c4bceeb7ed0376e26113c9d31522af8b4 /test/date.unit.js | |
| parent | cf0bd70d5fca9c0169414f5d2c16ca32431a3fd9 (diff) | |
| parent | d8f8108ac5dbec7e2b7ea9a23dd19aa42255e3fb (diff) | |
| download | faker-66996e280c9fbbbc2e7db376549f568be32ad5cd.tar.xz faker-66996e280c9fbbbc2e7db376549f568be32ad5cd.zip | |
Merge v3.0.1 into practicalmeteor:faker package branch
Diffstat (limited to 'test/date.unit.js')
| -rw-r--r-- | test/date.unit.js | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/test/date.unit.js b/test/date.unit.js index cc0cddc7..ffbc3201 100644 --- a/test/date.unit.js +++ b/test/date.unit.js @@ -78,4 +78,89 @@ describe("date.js", function () { assert.ok(date > from && date < to); }); }); + + describe("month()", function () { + it("returns random value from date.month.wide array by default", function () { + var month = faker.date.month(); + assert.ok(faker.definitions.date.month.wide.indexOf(month) !== -1); + }); + + it("returns random value from date.month.wide_context array for context option", function () { + var month = faker.date.month({ context: true }); + assert.ok(faker.definitions.date.month.wide_context.indexOf(month) !== -1); + }); + + it("returns random value from date.month.abbr array for abbr option", function () { + var month = faker.date.month({ abbr: true }); + assert.ok(faker.definitions.date.month.abbr.indexOf(month) !== -1); + }); + + it("returns random value from date.month.abbr_context array for abbr and context option", function () { + var month = faker.date.month({ abbr: true, context: true }); + assert.ok(faker.definitions.date.month.abbr_context.indexOf(month) !== -1); + }); + + it("returns random value from date.month.wide array for context option when date.month.wide_context array is missing", function () { + var backup_wide_context = faker.definitions.date.month.wide_context; + faker.definitions.date.month.wide_context = undefined; + + var month = faker.date.month({ context: true }); + assert.ok(faker.definitions.date.month.wide.indexOf(month) !== -1); + + faker.definitions.date.month.wide_context = backup_wide_context; + }); + + it("returns random value from date.month.abbr array for abbr and context option when date.month.abbr_context array is missing", function () { + var backup_abbr_context = faker.definitions.date.month.abbr_context; + faker.definitions.date.month.abbr_context = undefined; + + var month = faker.date.month({ abbr: true, context: true }); + assert.ok(faker.definitions.date.month.abbr.indexOf(month) !== -1); + + faker.definitions.date.month.abbr_context = backup_abbr_context; + }); + }); + + describe("weekday()", function () { + it("returns random value from date.weekday.wide array by default", function () { + var weekday = faker.date.weekday(); + assert.ok(faker.definitions.date.weekday.wide.indexOf(weekday) !== -1); + }); + + it("returns random value from date.weekday.wide_context array for context option", function () { + var weekday = faker.date.weekday({ context: true }); + assert.ok(faker.definitions.date.weekday.wide_context.indexOf(weekday) !== -1); + }); + + it("returns random value from date.weekday.abbr array for abbr option", function () { + var weekday = faker.date.weekday({ abbr: true }); + assert.ok(faker.definitions.date.weekday.abbr.indexOf(weekday) !== -1); + }); + + it("returns random value from date.weekday.abbr_context array for abbr and context option", function () { + var weekday = faker.date.weekday({ abbr: true, context: true }); + assert.ok(faker.definitions.date.weekday.abbr_context.indexOf(weekday) !== -1); + }); + + it("returns random value from date.weekday.wide array for context option when date.weekday.wide_context array is missing", function () { + var backup_wide_context = faker.definitions.date.weekday.wide_context; + faker.definitions.date.weekday.wide_context = undefined; + + var weekday = faker.date.weekday({ context: true }); + assert.ok(faker.definitions.date.weekday.wide.indexOf(weekday) !== -1); + + faker.definitions.date.weekday.wide_context = backup_wide_context; + }); + + it("returns random value from date.weekday.abbr array for abbr and context option when date.weekday.abbr_context array is missing", function () { + var backup_abbr_context = faker.definitions.date.weekday.abbr_context; + faker.definitions.date.weekday.abbr_context = undefined; + + var weekday = faker.date.weekday({ abbr: true, context: true }); + assert.ok(faker.definitions.date.weekday.abbr.indexOf(weekday) !== -1); + + faker.definitions.date.weekday.abbr_context = backup_abbr_context; + }); + }); + }); |
