diff options
| author | Marak <[email protected]> | 2015-07-08 23:56:22 -0700 |
|---|---|---|
| committer | Marak <[email protected]> | 2015-07-08 23:56:22 -0700 |
| commit | 4c1b454b8e3c8d87f2569a2ce0d7730dc31ee821 (patch) | |
| tree | 6fcbdb8eee0a7365c78043008c8dd5b6a51d39c5 | |
| parent | edb7d482a40e98ce25cd6ba296818be14f291aa1 (diff) | |
| download | faker-4c1b454b8e3c8d87f2569a2ce0d7730dc31ee821.tar.xz faker-4c1b454b8e3c8d87f2569a2ce0d7730dc31ee821.zip | |
[api] [refactor] Rename `array_element` and `object_element` to camelCase. Set default max random number to 99999. Added default arguments to some methods.
| -rw-r--r-- | lib/address.js | 22 | ||||
| -rw-r--r-- | lib/commerce.js | 12 | ||||
| -rw-r--r-- | lib/company.js | 14 | ||||
| -rw-r--r-- | lib/finance.js | 6 | ||||
| -rw-r--r-- | lib/hacker.js | 12 | ||||
| -rw-r--r-- | lib/helpers.js | 12 | ||||
| -rw-r--r-- | lib/image.js | 2 | ||||
| -rw-r--r-- | lib/internet.js | 12 | ||||
| -rw-r--r-- | lib/name.js | 28 | ||||
| -rw-r--r-- | lib/phone_number.js | 2 | ||||
| -rw-r--r-- | lib/random.js | 70 | ||||
| -rw-r--r-- | test/address.unit.js | 6 | ||||
| -rw-r--r-- | test/commerce.unit.js | 20 | ||||
| -rw-r--r-- | test/company.unit.js | 12 | ||||
| -rw-r--r-- | test/internet.unit.js | 6 | ||||
| -rw-r--r-- | test/name.unit.js | 6 | ||||
| -rw-r--r-- | test/random.unit.js | 6 |
17 files changed, 123 insertions, 125 deletions
diff --git a/lib/address.js b/lib/address.js index a921903f..c0a64f69 100644 --- a/lib/address.js +++ b/lib/address.js @@ -9,7 +9,7 @@ function Address (faker) { if (typeof localeFormat === 'string') { format = localeFormat; } else { - format = faker.random.array_element(localeFormat); + format = faker.random.arrayElement(localeFormat); } } return Helpers.replaceSymbols(format); @@ -32,11 +32,11 @@ function Address (faker) { } this.cityPrefix = function () { - return faker.random.array_element(faker.definitions.address.city_prefix); + return faker.random.arrayElement(faker.definitions.address.city_prefix); } this.citySuffix = function () { - return faker.random.array_element(faker.definitions.address.city_suffix); + return faker.random.arrayElement(faker.definitions.address.city_suffix); } this.streetName = function () { @@ -73,15 +73,15 @@ function Address (faker) { } this.streetSuffix = function () { - return faker.random.array_element(faker.definitions.address.street_suffix); + return faker.random.arrayElement(faker.definitions.address.street_suffix); } this.streetPrefix = function () { - return faker.random.array_element(faker.definitions.address.street_prefix); + return faker.random.arrayElement(faker.definitions.address.street_prefix); } this.secondaryAddress = function () { - return Helpers.replaceSymbolWithNumber(faker.random.array_element( + return Helpers.replaceSymbolWithNumber(faker.random.arrayElement( [ 'Apt. ###', 'Suite ###' @@ -90,23 +90,23 @@ function Address (faker) { } this.county = function () { - return faker.random.array_element(faker.definitions.address.county); + return faker.random.arrayElement(faker.definitions.address.county); } this.country = function () { - return faker.random.array_element(faker.definitions.address.country); + return faker.random.arrayElement(faker.definitions.address.country); } this.countryCode = function () { - return faker.random.array_element(faker.definitions.address.country_code); + return faker.random.arrayElement(faker.definitions.address.country_code); } this.state = function (useAbbr) { - return faker.random.array_element(faker.definitions.address.state); + return faker.random.arrayElement(faker.definitions.address.state); } this.stateAbbr = function () { - return faker.random.array_element(faker.definitions.address.state_abbr); + return faker.random.arrayElement(faker.definitions.address.state_abbr); } this.latitude = function () { diff --git a/lib/commerce.js b/lib/commerce.js index 276f1698..ec91edb1 100644 --- a/lib/commerce.js +++ b/lib/commerce.js @@ -2,12 +2,12 @@ var Commerce = function (faker) { var self = this; self.color = function() { - return faker.random.array_element(faker.definitions.commerce.color); + return faker.random.arrayElement(faker.definitions.commerce.color); }; self.department = function(max, fixedAmount) { - return faker.random.array_element(faker.definitions.commerce.department); + return faker.random.arrayElement(faker.definitions.commerce.department); /* max = max || 3; @@ -50,7 +50,7 @@ var Commerce = function (faker) { var categories = []; do { - var category = faker.random.array_element(faker.definitions.commerce.department); + var category = faker.random.arrayElement(faker.definitions.commerce.department); if(categories.indexOf(category) === -1) { categories.push(category); } @@ -72,15 +72,15 @@ var Commerce = function (faker) { */ self.productAdjective = function() { - return faker.random.array_element(faker.definitions.commerce.product_name.adjective); + return faker.random.arrayElement(faker.definitions.commerce.product_name.adjective); }; self.productMaterial = function() { - return faker.random.array_element(faker.definitions.commerce.product_name.material); + return faker.random.arrayElement(faker.definitions.commerce.product_name.material); }; self.product = function() { - return faker.random.array_element(faker.definitions.commerce.product_name.product); + return faker.random.arrayElement(faker.definitions.commerce.product_name.product); } return self; diff --git a/lib/company.js b/lib/company.js index d0f74357..f9fb0de3 100644 --- a/lib/company.js +++ b/lib/company.js @@ -24,7 +24,7 @@ var Company = function (faker) { } this.companySuffix = function () { - return faker.random.array_element(faker.company.suffixes()); + return faker.random.arrayElement(faker.company.suffixes()); } this.catchPhrase = function () { @@ -36,27 +36,27 @@ var Company = function (faker) { } this.catchPhraseAdjective = function () { - return faker.random.array_element(faker.definitions.company.adjective); + return faker.random.arrayElement(faker.definitions.company.adjective); } this.catchPhraseDescriptor = function () { - return faker.random.array_element(faker.definitions.company.descriptor); + return faker.random.arrayElement(faker.definitions.company.descriptor); } this.catchPhraseNoun = function () { - return faker.random.array_element(faker.definitions.company.noun); + return faker.random.arrayElement(faker.definitions.company.noun); } this.bsAdjective = function () { - return faker.random.array_element(faker.definitions.company.bs_adjective); + return faker.random.arrayElement(faker.definitions.company.bs_adjective); } this.bsBuzz = function () { - return faker.random.array_element(faker.definitions.company.bs_verb); + return faker.random.arrayElement(faker.definitions.company.bs_verb); } this.bsNoun = function () { - return faker.random.array_element(faker.definitions.company.bs_noun); + return faker.random.arrayElement(faker.definitions.company.bs_noun); } } diff --git a/lib/finance.js b/lib/finance.js index 89f5e285..0140cd19 100644 --- a/lib/finance.js +++ b/lib/finance.js @@ -66,18 +66,18 @@ var Finance = function (faker) { } self.currencyCode = function () { - return faker.random.object_element(faker.definitions.finance.currency)['code']; + return faker.random.objectElement(faker.definitions.finance.currency)['code']; } self.currencyName = function () { - return faker.random.object_element(faker.definitions.finance.currency, 'key'); + return faker.random.objectElement(faker.definitions.finance.currency, 'key'); } self.currencySymbol = function () { var symbol; while (!symbol) { - symbol = faker.random.object_element(faker.definitions.finance.currency)['symbol']; + symbol = faker.random.objectElement(faker.definitions.finance.currency)['symbol']; } return symbol; } diff --git a/lib/hacker.js b/lib/hacker.js index 7aba150e..463f8331 100644 --- a/lib/hacker.js +++ b/lib/hacker.js @@ -2,23 +2,23 @@ var Hacker = function (faker) { var self = this; self.abbreviation = function () { - return faker.random.array_element(faker.definitions.hacker.abbreviation); + return faker.random.arrayElement(faker.definitions.hacker.abbreviation); }; self.adjective = function () { - return faker.random.array_element(faker.definitions.hacker.adjective); + return faker.random.arrayElement(faker.definitions.hacker.adjective); }; self.noun = function () { - return faker.random.array_element(faker.definitions.hacker.noun); + return faker.random.arrayElement(faker.definitions.hacker.noun); }; self.verb = function () { - return faker.random.array_element(faker.definitions.hacker.verb); + return faker.random.arrayElement(faker.definitions.hacker.verb); }; self.ingverb = function () { - return faker.random.array_element(faker.definitions.hacker.ingverb); + return faker.random.arrayElement(faker.definitions.hacker.ingverb); }; self.phrase = function () { @@ -31,7 +31,7 @@ var Hacker = function (faker) { verb: self.verb() }; - var phrase = faker.random.array_element([ "If we {{verb}} the {{noun}}, we can get to the {{abbreviation}} {{noun}} through the {{adjective}} {{abbreviation}} {{noun}}!", + var phrase = faker.random.arrayElement([ "If we {{verb}} the {{noun}}, we can get to the {{abbreviation}} {{noun}} through the {{adjective}} {{abbreviation}} {{noun}}!", "We need to {{verb}} the {{adjective}} {{abbreviation}} {{noun}}!", "Try to {{verb}} the {{abbreviation}} {{noun}}, maybe it will {{verb}} the {{adjective}} {{noun}}!", "You can't {{verb}} the {{noun}} without {{ingverb}} the {{adjective}} {{abbreviation}} {{noun}}!", diff --git a/lib/helpers.js b/lib/helpers.js index d59cd241..ec8e1573 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -1,16 +1,11 @@ var Helpers = function (faker) { - + var self = this; - - // backword-compatibility - self.randomNumber = function (range) { - return faker.random.number(range); - }; // backword-compatibility self.randomize = function (array) { array = array || ["a", "b", "c"]; - return faker.random.array_element(array); + return faker.random.arrayElement(array); }; // slugifies string @@ -64,6 +59,9 @@ var Helpers = function (faker) { }; self.mustache = function (str, data) { + if (typeof str === 'undefined') { + return ''; + } for(var p in data) { var re = new RegExp('{{' + p + '}}', 'g') str = str.replace(re, data[p]); diff --git a/lib/image.js b/lib/image.js index e791ffea..01f7f5cb 100644 --- a/lib/image.js +++ b/lib/image.js @@ -4,7 +4,7 @@ var Image = function (faker) { self.image = function () { var categories = ["abstract", "animals", "business", "cats", "city", "food", "nightlife", "fashion", "people", "nature", "sports", "technics", "transport"]; - return self[faker.random.array_element(categories)](); + return self[faker.random.arrayElement(categories)](); }; self.avatar = function () { return faker.internet.avatar(); diff --git a/lib/internet.js b/lib/internet.js index fd9fd877..2663ce5c 100644 --- a/lib/internet.js +++ b/lib/internet.js @@ -4,11 +4,11 @@ var password_generator = require('../vendor/password-generator.js'), var Internet = function (faker) { var self = this; self.avatar = function () { - return faker.random.array_element(faker.definitions.internet.avatar_uri); + return faker.random.arrayElement(faker.definitions.internet.avatar_uri); }; self.email = function (firstName, lastName, provider) { - provider = provider || faker.random.array_element(faker.definitions.internet.free_email); + provider = provider || faker.random.arrayElement(faker.definitions.internet.free_email); return faker.helpers.slugify(faker.internet.userName(firstName, lastName)) + "@" + provider; }; @@ -21,10 +21,10 @@ var Internet = function (faker) { result = firstName + faker.random.number(99); break; case 1: - result = firstName + faker.random.array_element([".", "_"]) + lastName; + result = firstName + faker.random.arrayElement([".", "_"]) + lastName; break; case 2: - result = firstName + faker.random.array_element([".", "_"]) + lastName + faker.random.number(99); + result = firstName + faker.random.arrayElement([".", "_"]) + lastName + faker.random.number(99); break; } result = result.toString().replace(/'/g, ""); @@ -34,7 +34,7 @@ var Internet = function (faker) { self.protocol = function () { var protocols = ['http','https']; - return faker.random.array_element(protocols); + return faker.random.arrayElement(protocols); }; self.url = function () { @@ -46,7 +46,7 @@ var Internet = function (faker) { }; self.domainSuffix = function () { - return faker.random.array_element(faker.definitions.internet.domain_suffix); + return faker.random.arrayElement(faker.definitions.internet.domain_suffix); }; self.domainWord = function () { diff --git a/lib/name.js b/lib/name.js index 5f1c577f..ae1b05b9 100644 --- a/lib/name.js +++ b/lib/name.js @@ -8,12 +8,12 @@ function Name (faker) { gender = faker.random.number(1); } if (gender === 0) { - return faker.random.array_element(faker.locales[faker.locale].name.male_first_name) + return faker.random.arrayElement(faker.locales[faker.locale].name.male_first_name) } else { - return faker.random.array_element(faker.locales[faker.locale].name.female_first_name); + return faker.random.arrayElement(faker.locales[faker.locale].name.female_first_name); } } - return faker.random.array_element(faker.definitions.name.first_name); + return faker.random.arrayElement(faker.definitions.name.first_name); }; this.lastName = function (gender) { @@ -24,12 +24,12 @@ function Name (faker) { gender = faker.random.number(1); } if (gender === 0) { - return faker.random.array_element(faker.locales[faker.locale].name.male_last_name); + return faker.random.arrayElement(faker.locales[faker.locale].name.male_last_name); } else { - return faker.random.array_element(faker.locales[faker.locale].name.female_last_name); + return faker.random.arrayElement(faker.locales[faker.locale].name.female_last_name); } } - return faker.random.array_element(faker.definitions.name.last_name); + return faker.random.arrayElement(faker.definitions.name.last_name); }; this.findName = function (firstName, lastName, gender) { @@ -65,31 +65,31 @@ function Name (faker) { }; this.prefix = function () { - return faker.random.array_element(faker.definitions.name.prefix); + return faker.random.arrayElement(faker.definitions.name.prefix); }; this.suffix = function () { - return faker.random.array_element(faker.definitions.name.suffix); + return faker.random.arrayElement(faker.definitions.name.suffix); }; this.title = function() { - var descriptor = faker.random.array_element(faker.definitions.name.title.descriptor), - level = faker.random.array_element(faker.definitions.name.title.level), - job = faker.random.array_element(faker.definitions.name.title.job); + var descriptor = faker.random.arrayElement(faker.definitions.name.title.descriptor), + level = faker.random.arrayElement(faker.definitions.name.title.level), + job = faker.random.arrayElement(faker.definitions.name.title.job); return descriptor + " " + level + " " + job; }; this.jobDescriptor = function () { - return faker.random.array_element(faker.definitions.name.title.descriptor); + return faker.random.arrayElement(faker.definitions.name.title.descriptor); }; this.jobArea = function () { - return faker.random.array_element(faker.definitions.name.title.level); + return faker.random.arrayElement(faker.definitions.name.title.level); }; this.jobType = function () { - return faker.random.array_element(faker.definitions.name.title.job); + return faker.random.arrayElement(faker.definitions.name.title.job); }; } diff --git a/lib/phone_number.js b/lib/phone_number.js index f683832c..4489ea22 100644 --- a/lib/phone_number.js +++ b/lib/phone_number.js @@ -13,7 +13,7 @@ var Phone = function (faker) { }; self.phoneFormats = function () { - return faker.random.array_element(faker.definitions.phone_number.formats); + return faker.random.arrayElement(faker.definitions.phone_number.formats); }; return self; diff --git a/lib/random.js b/lib/random.js index 7d592849..2d37c551 100644 --- a/lib/random.js +++ b/lib/random.js @@ -5,50 +5,50 @@ function Random (faker) { // returns a single random number based on a max number or range this.number = function (options) { - if (typeof options === "number") { - options = { - max: options - }; - } - - options = options || {}; - - if (typeof options.min === "undefined") { - options.min = 0; - } - - if (typeof options.max === "undefined") { - options.max = 1; - } - if (typeof options.precision === "undefined") { - options.precision = 1; - } - - // Make the range inclusive of the max value - var max = options.max; - if (max >= 0) { - max += options.precision; - } - - var randomNumber = options.precision * Math.floor( - mersenne.rand(max / options.precision, options.min / options.precision)); - - return randomNumber; + if (typeof options === "number") { + options = { + max: options + }; + } + + options = options || {}; + + if (typeof options.min === "undefined") { + options.min = 0; + } + + if (typeof options.max === "undefined") { + options.max = 99999; + } + if (typeof options.precision === "undefined") { + options.precision = 1; + } + + // Make the range inclusive of the max value + var max = options.max; + if (max >= 0) { + max += options.precision; + } + + var randomNumber = options.precision * Math.floor( + mersenne.rand(max / options.precision, options.min / options.precision)); + + return randomNumber; } - + // takes an array and returns a random element of the array - this.array_element = function (array) { + this.arrayElement = function (array) { array = array || ["a", "b", "c"]; var r = faker.random.number({ max: array.length - 1 }); return array[r]; } // takes an object and returns the randomly key or value - this.object_element = function (object, field) { - object = object || {}; + this.objectElement = function (object, field) { + object = object || { "foo": "bar", "too": "car" }; var array = Object.keys(object); - var key = faker.random.array_element(array); + var key = faker.random.arrayElement(array); return field === "key" ? key : object[key]; } @@ -68,7 +68,7 @@ function Random (faker) { } return this; - + } module['exports'] = Random; diff --git a/test/address.unit.js b/test/address.unit.js index bfe9e0ce..1ea76452 100644 --- a/test/address.unit.js +++ b/test/address.unit.js @@ -161,7 +161,7 @@ describe("address.js", function () { describe("secondaryAddress()", function () { it("randomly chooses an Apt or Suite number", function () { - sinon.spy(faker.random, 'array_element'); + sinon.spy(faker.random, 'arrayElement'); var address = faker.address.secondaryAddress(); @@ -171,8 +171,8 @@ describe("address.js", function () { ]; assert.ok(address); - assert.ok(faker.random.array_element.calledWith(expected_array)); - faker.random.array_element.restore(); + assert.ok(faker.random.arrayElement.calledWith(expected_array)); + faker.random.arrayElement.restore(); }); }); diff --git a/test/commerce.unit.js b/test/commerce.unit.js index 759c3962..06445e34 100644 --- a/test/commerce.unit.js +++ b/test/commerce.unit.js @@ -23,18 +23,18 @@ describe("commerce.js", function() { /* it("should return only one value if we specify a maximum of one", function() { - sinon.spy(faker.random, 'array_element'); + sinon.spy(faker.random, 'arrayElement'); var department = faker.commerce.department(1); assert.strictEqual(department.split(" ").length, 1); - assert.ok(faker.random.array_element.calledOnce); + assert.ok(faker.random.arrayElement.calledOnce); - faker.random.array_element.restore(); + faker.random.arrayElement.restore(); }); it("should return the maxiumum value if we specify the fixed value", function() { - sinon.spy(faker.random, 'array_element'); + sinon.spy(faker.random, 'arrayElement'); var department = faker.commerce.department(5, true); @@ -43,29 +43,29 @@ describe("commerce.js", function() { // account for the separator assert.strictEqual(department.split(" ").length, 6); // Sometimes it will generate duplicates that aren't used in the final string, - // so we check if array_element has been called exactly or more than 5 times - assert.ok(faker.random.array_element.callCount >= 5); + // so we check if arrayElement has been called exactly or more than 5 times + assert.ok(faker.random.arrayElement.callCount >= 5); - faker.random.array_element.restore(); + faker.random.arrayElement.restore(); }); */ }); describe("productName()", function() { it("returns name comprising of an adjective, material and product", function() { - sinon.spy(faker.random, 'array_element'); + sinon.spy(faker.random, 'arrayElement'); sinon.spy(faker.commerce, 'productAdjective'); sinon.spy(faker.commerce, 'productMaterial'); sinon.spy(faker.commerce, 'product'); var name = faker.commerce.productName(); assert.ok(name.split(' ').length >= 3); - assert.ok(faker.random.array_element.calledThrice); + assert.ok(faker.random.arrayElement.calledThrice); assert.ok(faker.commerce.productAdjective.calledOnce); assert.ok(faker.commerce.productMaterial.calledOnce); assert.ok(faker.commerce.product.calledOnce); - faker.random.array_element.restore(); + faker.random.arrayElement.restore(); faker.commerce.productAdjective.restore(); faker.commerce.productMaterial.restore(); faker.commerce.product.restore(); diff --git a/test/company.unit.js b/test/company.unit.js index c324a4ba..f863d83d 100644 --- a/test/company.unit.js +++ b/test/company.unit.js @@ -59,19 +59,19 @@ describe("company.js", function () { describe("catchPhrase()", function () { it("returns phrase comprising of a catch phrase adjective, descriptor, and noun", function () { - sinon.spy(faker.random, 'array_element'); + sinon.spy(faker.random, 'arrayElement'); sinon.spy(faker.company, 'catchPhraseAdjective'); sinon.spy(faker.company, 'catchPhraseDescriptor'); sinon.spy(faker.company, 'catchPhraseNoun'); var phrase = faker.company.catchPhrase(); assert.ok(phrase.split(' ').length >= 3); - assert.ok(faker.random.array_element.calledThrice); + assert.ok(faker.random.arrayElement.calledThrice); assert.ok(faker.company.catchPhraseAdjective.calledOnce); assert.ok(faker.company.catchPhraseDescriptor.calledOnce); assert.ok(faker.company.catchPhraseNoun.calledOnce); - faker.random.array_element.restore(); + faker.random.arrayElement.restore(); faker.company.catchPhraseAdjective.restore(); faker.company.catchPhraseDescriptor.restore(); faker.company.catchPhraseNoun.restore(); @@ -80,19 +80,19 @@ describe("company.js", function () { describe("bs()", function () { it("returns phrase comprising of a BS adjective, buzz, and noun", function () { - sinon.spy(faker.random, 'array_element'); + sinon.spy(faker.random, 'arrayElement'); sinon.spy(faker.company, 'bsAdjective'); sinon.spy(faker.company, 'bsBuzz'); sinon.spy(faker.company, 'bsNoun'); var bs = faker.company.bs(); assert.ok(typeof bs === 'string'); - assert.ok(faker.random.array_element.calledThrice); + assert.ok(faker.random.arrayElement.calledThrice); assert.ok(faker.company.bsAdjective.calledOnce); assert.ok(faker.company.bsBuzz.calledOnce); assert.ok(faker.company.bsNoun.calledOnce); - faker.random.array_element.restore(); + faker.random.arrayElement.restore(); faker.company.bsAdjective.restore(); faker.company.bsBuzz.restore(); faker.company.bsNoun.restore(); diff --git a/test/internet.unit.js b/test/internet.unit.js index 1965a1bd..9218a56e 100644 --- a/test/internet.unit.js +++ b/test/internet.unit.js @@ -33,18 +33,18 @@ describe("internet.js", function () { sinon.stub(faker.random, 'number').returns(1); sinon.spy(faker.name, 'firstName'); sinon.spy(faker.name, 'lastName'); - sinon.spy(faker.random, 'array_element'); + sinon.spy(faker.random, 'arrayElement'); var username = faker.internet.userName(); assert.ok(username); assert.ok(faker.name.firstName.called); assert.ok(faker.name.lastName.called); - assert.ok(faker.random.array_element.calledWith(['.', '_'])); + assert.ok(faker.random.arrayElement.calledWith(['.', '_'])); faker.random.number.restore(); faker.name.firstName.restore(); faker.name.lastName.restore(); - faker.random.array_element.restore(); + faker.random.arrayElement.restore(); }); }); diff --git a/test/name.unit.js b/test/name.unit.js index bd3d4c23..e1d2e871 100644 --- a/test/name.unit.js +++ b/test/name.unit.js @@ -82,19 +82,19 @@ describe("name.js", function () { describe("jobTitle()", function () { it("returns a job title consisting of a descriptor, area, and type", function () { - sinon.spy(faker.random, 'array_element'); + sinon.spy(faker.random, 'arrayElement'); sinon.spy(faker.name, 'jobDescriptor'); sinon.spy(faker.name, 'jobArea'); sinon.spy(faker.name, 'jobType'); var jobTitle = faker.name.jobTitle(); assert.ok(typeof jobTitle === 'string'); - assert.ok(faker.random.array_element.calledThrice); + assert.ok(faker.random.arrayElement.calledThrice); assert.ok(faker.name.jobDescriptor.calledOnce); assert.ok(faker.name.jobArea.calledOnce); assert.ok(faker.name.jobType.calledOnce); - faker.random.array_element.restore(); + faker.random.arrayElement.restore(); faker.name.jobDescriptor.restore(); faker.name.jobArea.restore(); faker.name.jobType.restore(); diff --git a/test/random.unit.js b/test/random.unit.js index ad4ec1c2..201c2267 100644 --- a/test/random.unit.js +++ b/test/random.unit.js @@ -71,15 +71,15 @@ describe("random.js", function () { }); }); - describe('array_element', function() { + describe('arrayElement', function() { it('returns a random element in the array', function() { var testArray = ['hello', 'to', 'you', 'my', 'friend']; - assert.ok(testArray.indexOf(faker.random.array_element(testArray)) > -1); + assert.ok(testArray.indexOf(faker.random.arrayElement(testArray)) > -1); }); it('returns a random element in the array when there is only 1', function() { var testArray = ['hello']; - assert.ok(testArray.indexOf(faker.random.array_element(testArray)) > -1); + assert.ok(testArray.indexOf(faker.random.arrayElement(testArray)) > -1); }); }); |
