diff --git a/lib/fakerator.js b/lib/fakerator.js index cfe6b22b..e22e1634 100644 --- a/lib/fakerator.js +++ b/lib/fakerator.js @@ -250,13 +250,12 @@ module.exports = function(localeID = "default") { return self.generate(res, ...args); }; - /*function createGeneratorMethods(obj, definitions, level) { + function createGeneratorMethods(obj, definitions, level) { each(Object.keys(definitions), (item) => { if (item === "_meta") return; - console.log(item); let def = definitions[item]; - if (isObject(def) && level < 2) { + if (isObject(def) && !isArray(def) && !isFunction(def) && level < 10) { obj[item] = {}; createGeneratorMethods(obj[item], def, level + 1); } @@ -266,11 +265,11 @@ module.exports = function(localeID = "default") { }; } }); - }*/ + } - //createGeneratorMethods(self, self.locale, 1); + createGeneratorMethods(self, self.locale, 1); - + /* // Set helper functions from locale definitions each(Object.keys(self.locale), (category) => { if (category === "_meta") return; @@ -284,7 +283,7 @@ module.exports = function(localeID = "default") { //console.log("Set " + category + "." + item); }); - }); + });*/ return self; }; \ No newline at end of file diff --git a/test/specs/index.spec.js b/test/specs/index.spec.js index 19070e6d..fbd0f554 100644 --- a/test/specs/index.spec.js +++ b/test/specs/index.spec.js @@ -64,9 +64,4 @@ describe("Fakerator", () => { expect(fakerator.locale.lorem).to.be.an("Object"); }); - it.skip("generate", () => { - let fakerator = new Fakerator(); - - console.log(fakerator.generate(fakerator.locale.address.buildingNumber)); - }) -}) \ No newline at end of file +}); \ No newline at end of file diff --git a/test/specs/locales/hu-HU/index.spec.js b/test/specs/locales/hu-HU/index.spec.js index ae462544..90dd4058 100644 --- a/test/specs/locales/hu-HU/index.spec.js +++ b/test/specs/locales/hu-HU/index.spec.js @@ -46,7 +46,7 @@ describe("Locale hu-HU", () => { expect(fakerator.address.buildingNumber()).to.be.equal("5"); expect(fakerator.address.postCode()).to.be.equal("0086"); - //expect(fakerator.address.state()).to.be.undefined; + expect(fakerator.address.state()).to.be.undefined; }); it("check internet definitions", () => { @@ -56,35 +56,35 @@ describe("Locale hu-HU", () => { expect(fakerator.internet.email()).to.be.equal("rita19@gmail.com"); }); - it("check entity.user", () => { - let user = fakerator.entity.user(); - expect(user).to.be.an("Object"); - //console.log(user); - - expect(user).to.have.property("firstName").an("String"); - expect(user).to.have.property("lastName").an("String"); - expect(user).to.have.property("userName").an("String"); - expect(user).to.have.property("password").an("String"); - expect(user).to.have.property("email").an("String"); - expect(user).to.have.property("phone").an("String"); - expect(user).to.have.property("dob").an("Date"); - expect(user).to.have.property("website").an("String"); - expect(user).to.have.property("ip").an("String"); - expect(user).to.have.property("avatar").an("String"); - expect(user).to.have.property("gravatar").an("String"); - expect(user).to.have.property("status").an("Boolean"); - expect(user).to.have.property("address").an("Object"); - - expect(user.address).to.have.property("country").an("String"); - expect(user.address).to.have.property("countryCode").an("String").length(2); - //expect(user.address).to.have.not.property("state"); - expect(user.address).to.have.property("city").an("String"); - expect(user.address).to.have.property("street").an("String"); - expect(user.address).to.have.property("zip").an("String"); - expect(user.address).to.have.property("geo").an("Object"); - expect(user.address.geo).to.have.property("latitude").an("Number"); - expect(user.address.geo).to.have.property("longitude").an("Number"); - - }); + it("check entity.user", () => { + let user = fakerator.entity.user(); + expect(user).to.be.an("Object"); + //console.log(user); + + expect(user).to.have.property("firstName").an("String"); + expect(user).to.have.property("lastName").an("String"); + expect(user).to.have.property("userName").an("String"); + expect(user).to.have.property("password").an("String"); + expect(user).to.have.property("email").an("String"); + expect(user).to.have.property("phone").an("String"); + expect(user).to.have.property("dob").an("Date"); + expect(user).to.have.property("website").an("String"); + expect(user).to.have.property("ip").an("String"); + expect(user).to.have.property("avatar").an("String"); + expect(user).to.have.property("gravatar").an("String"); + expect(user).to.have.property("status").an("Boolean"); + expect(user).to.have.property("address").an("Object"); + + expect(user.address).to.have.property("country").an("String"); + expect(user.address).to.have.property("countryCode").an("String").length(2); + expect(user.address.state).to.be.undefined; + expect(user.address).to.have.property("city").an("String"); + expect(user.address).to.have.property("street").an("String"); + expect(user.address).to.have.property("zip").an("String"); + expect(user.address).to.have.property("geo").an("Object"); + expect(user.address.geo).to.have.property("latitude").an("Number"); + expect(user.address.geo).to.have.property("longitude").an("Number"); + + }); }) \ No newline at end of file