diff options
| author | Tyler <[email protected]> | 2017-10-21 14:48:03 -0700 |
|---|---|---|
| committer | Tyler <[email protected]> | 2017-10-21 14:48:03 -0700 |
| commit | 9239055a242ea71d78f7f7c67014b1436c040862 (patch) | |
| tree | 27edfa07783666a85486aff2ba4978ecf873f36c | |
| parent | 4179b203e380811272ef7e75ce11d62458cd7e75 (diff) | |
| download | faker-9239055a242ea71d78f7f7c67014b1436c040862.tar.xz faker-9239055a242ea71d78f7f7c67014b1436c040862.zip | |
add unit tests and schema desciptions
| -rw-r--r-- | lib/address.js | 19 | ||||
| -rw-r--r-- | lib/index.js | 2 | ||||
| -rw-r--r-- | test/address.unit.js | 19 |
3 files changed, 34 insertions, 6 deletions
diff --git a/lib/address.js b/lib/address.js index 59328c46..cb74da39 100644 --- a/lib/address.js +++ b/lib/address.js @@ -230,26 +230,35 @@ function Address (faker) { /** * cardinal direction * - * @method faker.address.cardDirection + * @method faker.address.cardinalDirection */ - this.cardDirection = function () { + this.cardinalDirection = function () { return faker.random.arrayElement(faker.definitions.address.direction); } + this.cardinalDirection.schema = { + "description": "Generates a cardinal direction.", + "sampleResults": ["N", "S", "E", "W"] + }; + /** * ordinal direction * - * @method faker.address.ordDirection + * @method faker.address.ordinalDirection */ - this.ordDirection = function () { + this.ordinalDirection = function () { return ( faker.random.arrayElement(faker.definitions.address.direction.slice(0, 2)) + faker.random.arrayElement(faker.definitions.address.direction.slice(2, 4)) ); } + this.ordinalDirection.schema = { + "description": "Generates an ordinal direction.", + "sampleResults": ["NW", "SE", "SW", "NE"] + }; + return this; } - module.exports = Address; diff --git a/lib/index.js b/lib/index.js index 58f0012e..08f45b78 100644 --- a/lib/index.js +++ b/lib/index.js @@ -101,7 +101,7 @@ function Faker (opts) { var _definitions = { "name": ["first_name", "last_name", "prefix", "suffix", "gender", "title", "male_first_name", "female_first_name", "male_middle_name", "female_middle_name", "male_last_name", "female_last_name"], - "address": ["city_prefix", "city_suffix", "street_suffix", "county", "country", "country_code", "state", "state_abbr", "street_prefix", "postcode"], + "address": ["city_prefix", "city_suffix", "street_suffix", "county", "country", "country_code", "state", "state_abbr", "street_prefix", "postcode", "direction"], "company": ["adjective", "noun", "descriptor", "bs_adjective", "bs_noun", "bs_verb", "suffix"], "lorem": ["words"], "hacker": ["abbreviation", "adjective", "noun", "verb", "ingverb", "phrase"], diff --git a/test/address.unit.js b/test/address.unit.js index 5aba2c36..5a31724b 100644 --- a/test/address.unit.js +++ b/test/address.unit.js @@ -308,4 +308,23 @@ describe("address.js", function () { }); }); + describe("ordinalDirection()", function () { + it("returns random ordinal direction", function () { + sinon.stub(faker.address, 'ordinalDirection').returns('W'); + var ordinalDirection = faker.address.ordinalDirection(); + + assert.equal(ordinalDirection, 'W'); + faker.address.ordinalDirection.restore(); + }) + }) + + describe("cardinalDirection()", function () { + it("returns random cardinal direction", function () { + sinon.stub(faker.address, 'cardinalDirection').returns('NW'); + var cardinalDirection = faker.address.cardinalDirection(); + + assert.equal(cardinalDirection, 'NW'); + faker.address.cardinalDirection.restore(); + }) + }) }); |
