Skip to content

Commit

Permalink
⭐ new: email generator with domain parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
icebob committed May 25, 2016
1 parent f5ac1c9 commit 6214433
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
# TODO
- middle name
- gravatar
- color with #
- email with domain parameter
- ipv6
- country name and code same
- times n variable as object {min: 1, max: 100} and select a random n
Expand Down
11 changes: 6 additions & 5 deletions lib/locales/default/internet/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,16 @@ module.exports = {
"hotmail.com"
],

email(firstName, lastName) {
email(firstName, lastName, domain) {
firstName = this.slugify(firstName ? firstName : this.populate("#{names.firstName}")).toLowerCase();
lastName = this.slugify(lastName ? lastName : this.populate("#{names.lastName}")).toLowerCase();
domain = domain ? domain : this.populate("#{internet.emailDomain}");

return [
`${firstName}.${lastName}@#{internet.emailDomain}`,
`${firstName}.${lastName}##@#{internet.emailDomain}`,
`${firstName}${lastName}##@#{internet.emailDomain}`,
`${firstName}##@#{internet.emailDomain}`
`${firstName}.${lastName}@${domain}`,
`${firstName}.${lastName}##@${domain}`,
`${firstName}${lastName}##@${domain}`,
`${firstName}##@${domain}`
];
},

Expand Down
13 changes: 7 additions & 6 deletions test/specs/locales/default/internet.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,14 @@ describe("Default internet", () => {
});

it("check internet.email", () => {
expect(fakerator.populate("#{internet.email}")).to.be.equal("kelly.moore43@gmail.com");
expect(fakerator.internet.email()).to.be.equal("annette.mante60@gmail.com");
expect(fakerator.populate("#{internet.email}")).to.be.equal("kelly.moore@gmail.com");
expect(fakerator.internet.email()).to.be.equal("vernonheidenreich43@hotmail.com");
});

it("check internet.email with name parameters", () => {
expect(fakerator.populate("#{internet.email}", "John", "Doe")).to.be.equal("johndoe96@gmail.com");
expect(fakerator.internet.email("Jane", "Doe")).to.be.equal("jane.doe43@gmail.com");
expect(fakerator.populate("#{internet.email}", "John", "Doe")).to.be.equal("john.doe@hotmail.com");
expect(fakerator.internet.email("Jane", "Doe")).to.be.equal("janedoe21@hotmail.com");
expect(fakerator.internet.email(null, null, "company.org")).to.be.equal("vernonheidenreich54@company.org");
});

it("check internet.imageCategories", () => {
Expand Down Expand Up @@ -90,8 +91,8 @@ describe("Default internet", () => {
});

it("check internet.gravatar", () => {
expect(fakerator.populate("#{internet.gravatar}")).to.be.equal("//www.gravatar.com/avatar/43773e15060b15aca46d63cf57a7d60e");
expect(fakerator.internet.gravatar()).to.be.equal("//www.gravatar.com/avatar/833e19911ae57b595fdd535c51be0b42");
expect(fakerator.populate("#{internet.gravatar}")).to.be.equal("//www.gravatar.com/avatar/a91004b566f80271f0a3577f71d43cd4");
expect(fakerator.internet.gravatar()).to.be.equal("//www.gravatar.com/avatar/06ba08b465e85247620b410fbb26dacf");
expect(fakerator.internet.gravatar("john.doe@gmail.com")).to.be.equal("//www.gravatar.com/avatar/e13743a7f1db7f4246badd6fd6ff54ff");
});

Expand Down

0 comments on commit 6214433

Please sign in to comment.