diff options
| author | Marak <[email protected]> | 2015-07-06 08:41:31 -0700 |
|---|---|---|
| committer | Marak <[email protected]> | 2015-07-06 08:41:31 -0700 |
| commit | 760a2c5e92011cc60286e55447e6cc168c1b86c6 (patch) | |
| tree | 62a1c2247e0c9c2e7c49e36bdabdbd763a298c73 | |
| parent | 376068f29223ade15278acb75731e23db2098b0a (diff) | |
| parent | 4a5de1ab467cba4dd4b61ed5a16f6816fb7c38f9 (diff) | |
| download | faker-760a2c5e92011cc60286e55447e6cc168c1b86c6.tar.xz faker-760a2c5e92011cc60286e55447e6cc168c1b86c6.zip | |
[merge] country_code branch
| -rw-r--r-- | index.js | 2 | ||||
| -rw-r--r-- | lib/address.js | 6 | ||||
| -rw-r--r-- | test/address.unit.js | 18 |
3 files changed, 20 insertions, 6 deletions
@@ -43,7 +43,7 @@ exports.definitions = {}; var _definitions = { "name": ["first_name", "last_name", "prefix", "suffix", "title", "male_first_name", "male_last_name", "female_first_name", "female_last_name"], - "address": ["city_prefix", "city_suffix", "street_suffix", "county", "country", "state", "state_abbr", "street_prefix"], + "address": ["city_prefix", "city_suffix", "street_suffix", "county", "country", "country_code", "state", "state_abbr", "street_prefix"], "company": ["adjective", "noun", "descriptor", "bs_adjective", "bs_noun", "bs_verb", "suffix"], "lorem": ["words"], "hacker": ["abbreviation", "adjective", "noun", "verb", "ingverb"], diff --git a/lib/address.js b/lib/address.js index 094f9872..261f2758 100644 --- a/lib/address.js +++ b/lib/address.js @@ -90,7 +90,11 @@ var address = { return faker.random.array_element(faker.definitions.address.country); }, - state: function () { + countryCode: function () { + return faker.random.array_element(faker.definitions.address.country_code); + }, + + state: function (useAbbr) { return faker.random.array_element(faker.definitions.address.state); }, diff --git a/test/address.unit.js b/test/address.unit.js index b03a3be4..f6b299a1 100644 --- a/test/address.unit.js +++ b/test/address.unit.js @@ -63,7 +63,7 @@ describe("address.js", function () { assert.ok(faker.address.citySuffix.calledOnce); }); }); - + describe("streetName()", function () { beforeEach(function () { @@ -100,8 +100,8 @@ describe("address.js", function () { assert.ok(faker.address.streetSuffix.calledOnce); }); }); - - + + describe("streetAddress()", function () { beforeEach(function () { @@ -157,7 +157,7 @@ describe("address.js", function () { }); }); }); - + describe("secondaryAddress()", function () { it("randomly chooses an Apt or Suite number", function () { @@ -196,6 +196,16 @@ describe("address.js", function () { }); }); + describe("countryCode()", function () { + it("returns random countryCode", function () { + sinon.spy(faker.address, 'countryCode'); + var countryCode = faker.address.countryCode(); + assert.ok(countryCode); + assert.ok(faker.address.countryCode.called); + faker.address.countryCode.restore(); + }); + }); + describe("state()", function () { it("returns random state", function () { sinon.spy(faker.address, 'state'); |
