diff options
| author | JKillian <[email protected]> | 2014-12-09 16:22:03 -0500 |
|---|---|---|
| committer | JKillian <[email protected]> | 2014-12-09 16:22:03 -0500 |
| commit | 3ee7219df7a2d5353fe171b2c30b864d5e0c3a31 (patch) | |
| tree | eaf72113fea2f2bcfc449477f33f58907ea7d8fe /test | |
| parent | daa9f442797525c9547c329665b4e9107b41d375 (diff) | |
| download | faker-3ee7219df7a2d5353fe171b2c30b864d5e0c3a31.tar.xz faker-3ee7219df7a2d5353fe171b2c30b864d5e0c3a31.zip | |
Add new jobTitle function to name object.
I had to make a few concessions when doing this.
Ideally I would have added this function under the 'company' module,
but I chose to add it to the 'name' object instead,
as the data happened to already exist in the locale files under
'name.title'.
However, I felt that the field names in the locale files were confusing,
so their wrappers in the name module are renamed for clarity.
For example, faker.name.jobArea() returns a random element from
locale.name.title.level. In my opinion, 'jobArea' was a much better
description of the data than 'level'.
Finally, fixed a bug in one unit test which didn't restore a function
to its original state after watching it.
Diffstat (limited to 'test')
| -rw-r--r-- | test/all.functional.js | 2 | ||||
| -rw-r--r-- | test/internet.unit.js | 1 | ||||
| -rw-r--r-- | test/name.unit.js | 21 |
3 files changed, 23 insertions, 1 deletions
diff --git a/test/all.functional.js b/test/all.functional.js index 1a2e836a..0aefec5f 100644 --- a/test/all.functional.js +++ b/test/all.functional.js @@ -18,7 +18,7 @@ var modules = { lorem: ['words', 'sentence', 'sentences', 'paragraph', 'paragraphs'], - name: ['firstName', 'lastName', 'findName'], + name: ['firstName', 'lastName', 'findName', 'jobTitle'], phone: ['phoneNumber'], diff --git a/test/internet.unit.js b/test/internet.unit.js index 2fc0db10..ecc03c39 100644 --- a/test/internet.unit.js +++ b/test/internet.unit.js @@ -44,6 +44,7 @@ describe("internet.js", function () { faker.random.number.restore(); faker.name.firstName.restore(); faker.name.lastName.restore(); + faker.random.array_element.restore(); }); }); diff --git a/test/name.unit.js b/test/name.unit.js index b34cbd1b..a9d8fa6f 100644 --- a/test/name.unit.js +++ b/test/name.unit.js @@ -67,4 +67,25 @@ describe("name.js", function () { var name = faker.name.findName(); }); }); + + 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.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.name.jobDescriptor.calledOnce); + assert.ok(faker.name.jobArea.calledOnce); + assert.ok(faker.name.jobType.calledOnce); + + faker.random.array_element.restore(); + faker.name.jobDescriptor.restore(); + faker.name.jobArea.restore(); + faker.name.jobType.restore(); + }); + }); }); |
