aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMarak <[email protected]>2015-07-08 23:56:22 -0700
committerMarak <[email protected]>2015-07-08 23:56:22 -0700
commit4c1b454b8e3c8d87f2569a2ce0d7730dc31ee821 (patch)
tree6fcbdb8eee0a7365c78043008c8dd5b6a51d39c5 /test
parentedb7d482a40e98ce25cd6ba296818be14f291aa1 (diff)
downloadfaker-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.
Diffstat (limited to 'test')
-rw-r--r--test/address.unit.js6
-rw-r--r--test/commerce.unit.js20
-rw-r--r--test/company.unit.js12
-rw-r--r--test/internet.unit.js6
-rw-r--r--test/name.unit.js6
-rw-r--r--test/random.unit.js6
6 files changed, 28 insertions, 28 deletions
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);
});
});