From 6214433d1ed542cb0e2ddd7e20a71b689b90354b Mon Sep 17 00:00:00 2001 From: Icebob Date: Wed, 25 May 2016 11:08:04 +0200 Subject: [PATCH] :star: new: email generator with domain parameter --- README.md | 2 -- lib/locales/default/internet/index.js | 11 ++++++----- test/specs/locales/default/internet.spec.js | 13 +++++++------ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index fce378e3..02b464d8 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/lib/locales/default/internet/index.js b/lib/locales/default/internet/index.js index 48ac292b..7540e0a7 100644 --- a/lib/locales/default/internet/index.js +++ b/lib/locales/default/internet/index.js @@ -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}` ]; }, diff --git a/test/specs/locales/default/internet.spec.js b/test/specs/locales/default/internet.spec.js index 8734349c..a61b7b21 100644 --- a/test/specs/locales/default/internet.spec.js +++ b/test/specs/locales/default/internet.spec.js @@ -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", () => { @@ -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"); });