Skip to content

Commit

Permalink
Completely removing aliased lower-case functions
Browse files Browse the repository at this point in the history
  • Loading branch information
BryanDonovan committed Jan 7, 2013
1 parent c7c3629 commit 504607f
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 54 deletions.
9 changes: 0 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,3 @@ exports.Lorem = require('./lib/lorem');
exports.Helpers = require('./lib/helpers');
exports.random = require('./lib/random');
exports.definitions = require('./lib/definitions');

// Aliases
exports.name = exports.Name;
exports.address = exports.Address;
exports.phoneNumber = exports.PhoneNumber;
exports.internet = exports.Internet;
exports.company = exports.Company;
exports.lorem = exports.Lorem;
exports.helpers = exports.Helpers;
42 changes: 21 additions & 21 deletions test/address.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe("address.js", function () {
it("occasionally returns prefix + first name + suffix", function () {
sinon.stub(Faker.random, 'number').returns(0);

var city = Faker.address.city();
var city = Faker.Address.city();
assert.ok(city);

assert.ok(Faker.random.city_prefix.calledOnce);
Expand All @@ -34,7 +34,7 @@ describe("address.js", function () {
it("occasionally returns prefix + first name", function () {
sinon.stub(Faker.random, 'number').returns(1);

var city = Faker.address.city();
var city = Faker.Address.city();
assert.ok(city);

assert.ok(Faker.random.city_prefix.calledOnce);
Expand All @@ -45,7 +45,7 @@ describe("address.js", function () {
it("occasionally returns first name + suffix", function () {
sinon.stub(Faker.random, 'number').returns(2);

var city = Faker.address.city();
var city = Faker.Address.city();
assert.ok(city);

assert.ok(!Faker.random.city_prefix.called);
Expand All @@ -56,7 +56,7 @@ describe("address.js", function () {
it("occasionally returns last name + suffix", function () {
sinon.stub(Faker.random, 'number').returns(3);

var city = Faker.address.city();
var city = Faker.Address.city();
assert.ok(city);

assert.ok(!Faker.random.city_prefix.called);
Expand All @@ -83,7 +83,7 @@ describe("address.js", function () {
it("occasionally returns last name + suffix", function () {
sinon.stub(Faker.random, 'number').returns(0);

var street_name = Faker.address.streetName();
var street_name = Faker.Address.streetName();
assert.ok(street_name);

assert.ok(!Faker.random.first_name.called);
Expand All @@ -94,7 +94,7 @@ describe("address.js", function () {
it("occasionally returns first name + suffix", function () {
sinon.stub(Faker.random, 'number').returns(1);

var street_name = Faker.address.streetName();
var street_name = Faker.Address.streetName();
assert.ok(street_name);

assert.ok(Faker.random.first_name.calledOnce);
Expand All @@ -105,55 +105,55 @@ describe("address.js", function () {

describe("streetAddress()", function () {
beforeEach(function () {
sinon.spy(Faker.address, 'streetName');
sinon.spy(Faker.address, 'secondaryAddress');
sinon.spy(Faker.Address, 'streetName');
sinon.spy(Faker.Address, 'secondaryAddress');
});

afterEach(function () {
Faker.address.streetName.restore();
Faker.address.secondaryAddress.restore();
Faker.Address.streetName.restore();
Faker.Address.secondaryAddress.restore();
});

it("occasionally returns a 5-digit street number", function () {
sinon.stub(Faker.random, 'number').returns(0);
var address = Faker.address.streetAddress();
var address = Faker.Address.streetAddress();
var parts = address.split(' ');

assert.equal(parts[0].length, 5);
assert.ok(Faker.address.streetName.called);
assert.ok(Faker.Address.streetName.called);

Faker.random.number.restore();
});

it("occasionally returns a 4-digit street number", function () {
sinon.stub(Faker.random, 'number').returns(1);
var address = Faker.address.streetAddress();
var address = Faker.Address.streetAddress();
var parts = address.split(' ');

assert.equal(parts[0].length, 4);
assert.ok(Faker.address.streetName.called);
assert.ok(Faker.Address.streetName.called);

Faker.random.number.restore();
});

it("occasionally returns a 3-digit street number", function () {
sinon.stub(Faker.random, 'number').returns(2);
var address = Faker.address.streetAddress();
var address = Faker.Address.streetAddress();
var parts = address.split(' ');

assert.equal(parts[0].length, 3);
assert.ok(Faker.address.streetName.called);
assert.ok(!Faker.address.secondaryAddress.called);
assert.ok(Faker.Address.streetName.called);
assert.ok(!Faker.Address.secondaryAddress.called);

Faker.random.number.restore();
});

context("when useFulladdress is true", function () {
it("adds a secondary address to the result", function () {
var address = Faker.address.streetAddress(true);
var address = Faker.Address.streetAddress(true);
var parts = address.split(' ');

assert.ok(Faker.address.secondaryAddress.called);
assert.ok(Faker.Address.secondaryAddress.called);
});
});
});
Expand All @@ -175,7 +175,7 @@ describe("address.js", function () {

context("when useAbbr is true", function () {
it("returns a br_state_abbr", function () {
var state = Faker.address.brState(true);
var state = Faker.Address.brState(true);

assert.ok(state);
assert.ok(Faker.random.br_state_abbr.called);
Expand All @@ -185,7 +185,7 @@ describe("address.js", function () {

context("when useAbbr is not set", function () {
it("returns a br_state", function () {
var state = Faker.address.brState();
var state = Faker.Address.brState();

assert.ok(state);
assert.ok(!Faker.random.br_state_abbr.called);
Expand Down
8 changes: 0 additions & 8 deletions test/all.functional.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,6 @@ var modules = {
PhoneNumber: ['phoneNumber']
};

// Backward compatibility.
modules.address = modules.Address;
modules.company = modules.Company;
modules.internet = modules.Internet;
modules.lorem = modules.Lorem;
modules.name = modules.Name;
modules.phoneNumber = modules.PhoneNumber;

describe("functional tests", function () {
Object.keys(modules).forEach(function (module) {
describe(module, function () {
Expand Down
22 changes: 11 additions & 11 deletions test/company.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe("company.js", function () {
describe("companyName()", function () {
it("lets you specify the type of name to return", function () {
sinon.spy(Faker.Helpers, 'randomNumber');
var name = Faker.company.companyName(1);
var name = Faker.Company.companyName(1);

assert.ok(name.match(/-/));

Expand All @@ -18,7 +18,7 @@ describe("company.js", function () {
it("sometimes returns three last names", function () {
sinon.spy(Faker.random, 'last_name');
sinon.stub(Faker.random, 'number').returns(2);
var name = Faker.company.companyName();
var name = Faker.Company.companyName();
var parts = name.split(' ');

assert.strictEqual(parts.length, 4); // account for word 'and'
Expand All @@ -31,7 +31,7 @@ describe("company.js", function () {
it("sometimes returns two last names separated by a hyphen", function () {
sinon.spy(Faker.random, 'last_name');
sinon.stub(Faker.random, 'number').returns(1);
var name = Faker.company.companyName();
var name = Faker.Company.companyName();
var parts = name.split('-');

assert.ok(parts.length >= 2);
Expand All @@ -42,26 +42,26 @@ describe("company.js", function () {
});

it("sometimes returns a last name with a company suffix", function () {
sinon.spy(Faker.company, 'companySuffix');
sinon.spy(Faker.Company, 'companySuffix');
sinon.spy(Faker.random, 'last_name');
sinon.stub(Faker.random, 'number').returns(0);
var name = Faker.company.companyName();
var name = Faker.Company.companyName();
var parts = name.split(' ');

assert.ok(parts.length >= 2);
assert.ok(Faker.random.last_name.calledOnce);
assert.ok(Faker.company.companySuffix.calledOnce);
assert.ok(Faker.Company.companySuffix.calledOnce);

Faker.random.number.restore();
Faker.random.last_name.restore();
Faker.company.companySuffix.restore();
Faker.Company.companySuffix.restore();
});
});

describe("companySuffix()", function () {
it("returns random value from company.suffixes array", function () {
var suffix = Faker.company.companySuffix();
assert.ok(Faker.company.suffixes.indexOf(suffix) !== -1);
var suffix = Faker.Company.companySuffix();
assert.ok(Faker.Company.suffixes.indexOf(suffix) !== -1);
});
});

Expand All @@ -71,7 +71,7 @@ describe("company.js", function () {
sinon.spy(Faker.random, 'catch_phrase_adjective');
sinon.spy(Faker.random, 'catch_phrase_descriptor');
sinon.spy(Faker.random, 'catch_phrase_noun');
var phrase = Faker.company.catchPhrase();
var phrase = Faker.Company.catchPhrase();

assert.ok(phrase.split(' ').length >= 3);
assert.ok(Faker.random.array_rand.calledThrice);
Expand All @@ -92,7 +92,7 @@ describe("company.js", function () {
sinon.spy(Faker.random, 'bs_adjective');
sinon.spy(Faker.random, 'bs_buzz');
sinon.spy(Faker.random, 'bs_noun');
var bs = Faker.company.bs();
var bs = Faker.Company.bs();

assert.ok(typeof bs === 'string');
assert.ok(Faker.random.array_rand.calledThrice);
Expand Down
10 changes: 5 additions & 5 deletions test/name.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe("name.js", function () {
describe("firstName()", function () {
it("returns a random name", function () {
sinon.stub(Faker.random, 'first_name').returns('foo');
var first_name = Faker.name.firstName();
var first_name = Faker.Name.firstName();

assert.equal(first_name, 'foo');

Expand All @@ -19,7 +19,7 @@ describe("name.js", function () {
it("returns a random name", function () {
sinon.stub(Faker.random, 'last_name').returns('foo');

var last_name = Faker.name.lastName();
var last_name = Faker.Name.lastName();

assert.equal(last_name, 'foo');

Expand All @@ -30,7 +30,7 @@ describe("name.js", function () {
describe("findName()", function () {
it("usually returns a first name and last name", function () {
sinon.stub(Faker.random, 'number').returns(5);
var name = Faker.name.findName();
var name = Faker.Name.findName();
assert.ok(name);
var parts = name.split(' ');

Expand All @@ -41,7 +41,7 @@ describe("name.js", function () {

it("occasionally returns a first name and last name with a prefix", function () {
sinon.stub(Faker.random, 'number').returns(0);
var name = Faker.name.findName();
var name = Faker.Name.findName();
var parts = name.split(' ');

assert.ok(parts.length >= 3);
Expand All @@ -51,7 +51,7 @@ describe("name.js", function () {

it("occasionally returns a first name and last name with a suffix", function () {
sinon.stub(Faker.random, 'number').returns(1);
var name = Faker.name.findName();
var name = Faker.Name.findName();
var parts = name.split(' ');

assert.ok(parts.length >= 3);
Expand Down

0 comments on commit 504607f

Please sign in to comment.