From 3ee7219df7a2d5353fe171b2c30b864d5e0c3a31 Mon Sep 17 00:00:00 2001 From: JKillian Date: Tue, 9 Dec 2014 16:22:03 -0500 Subject: 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. --- test/internet.unit.js | 1 + 1 file changed, 1 insertion(+) (limited to 'test/internet.unit.js') 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(); }); }); -- cgit v1.2.3 From 291464fdd87593246b51979a1ba41a03a3592683 Mon Sep 17 00:00:00 2001 From: Daniel Mills Date: Sun, 25 Jan 2015 15:35:36 -0500 Subject: added protocol() and url() --- test/internet.unit.js | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'test/internet.unit.js') diff --git a/test/internet.unit.js b/test/internet.unit.js index 2fc0db10..1f8893a3 100644 --- a/test/internet.unit.js +++ b/test/internet.unit.js @@ -73,6 +73,44 @@ describe("internet.js", function () { }); }); + describe('protocol()', function () { + it('returns a valid protocol', function () { + var protocol = faker.internet.protocol(); + assert.ok(protocol); + }); + + it('should occasionally return http', function () { + sinon.stub(faker.random, 'number').returns(0); + var protocol = faker.internet.protocol(); + assert.ok(protocol); + assert.strictEqual(protocol, 'http'); + + faker.random.number.restore(); + }); + + it('should occasionally return https', function () { + sinon.stub(faker.random, 'number').returns(1); + var protocol = faker.internet.protocol(); + assert.ok(protocol); + assert.strictEqual(protocol, 'https'); + + faker.random.number.restore(); + }); + }); + + describe('url()', function () { + it('returns a valid url', function () { + sinon.stub(faker.internet,'protocol').returns('http'); + sinon.stub(faker.internet, 'domainWord').returns('bar'); + sinon.stub(faker.internet, 'domainSuffix').returns('net'); + + var url = faker.internet.url(); + + assert.ok(url); + assert.strictEqual(url,'http://bar.net'); + }); + }); + describe("ip()", function () { it("returns a random IP address with four parts", function () { var ip = faker.internet.ip(); -- cgit v1.2.3 From 8b7bdd431c7dd38f004847771083df6684d28f7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ferreira?= Date: Sat, 13 Jun 2015 17:36:13 -0300 Subject: Including a MAC Address generator --- test/internet.unit.js | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test/internet.unit.js') diff --git a/test/internet.unit.js b/test/internet.unit.js index 1f8893a3..679881a7 100644 --- a/test/internet.unit.js +++ b/test/internet.unit.js @@ -132,4 +132,11 @@ describe("internet.js", function () { assert.ok(color.match(/^#[a-f0-9]{6}$/)); }); }); + + describe("macAddess()", function () { + it("returns a random MAC address with 6 hexadecimal digits", function () { + var mac = faker.internet.mac(); + assert.ok(mac.match(/^([a-f0-9]{2}:){5}[a-f0-9]{2}$/)); + }); + }); }); -- cgit v1.2.3 From 888c6469bfeec476333e16e3be4217b9cdf33753 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ferreira?= Date: Sat, 13 Jun 2015 17:38:59 -0300 Subject: Fixing method name references to mac generator in tests --- test/internet.unit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/internet.unit.js') diff --git a/test/internet.unit.js b/test/internet.unit.js index 679881a7..a18c1cc4 100644 --- a/test/internet.unit.js +++ b/test/internet.unit.js @@ -133,7 +133,7 @@ describe("internet.js", function () { }); }); - describe("macAddess()", function () { + describe("mac()", function () { it("returns a random MAC address with 6 hexadecimal digits", function () { var mac = faker.internet.mac(); assert.ok(mac.match(/^([a-f0-9]{2}:){5}[a-f0-9]{2}$/)); -- cgit v1.2.3 From 4c1b454b8e3c8d87f2569a2ce0d7730dc31ee821 Mon Sep 17 00:00:00 2001 From: Marak Date: Wed, 8 Jul 2015 23:56:22 -0700 Subject: [api] [refactor] Rename `array_element` and `object_element` to camelCase. Set default max random number to 99999. Added default arguments to some methods. --- test/internet.unit.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test/internet.unit.js') diff --git a/test/internet.unit.js b/test/internet.unit.js index 1965a1bd..9218a56e 100644 --- a/test/internet.unit.js +++ b/test/internet.unit.js @@ -33,18 +33,18 @@ describe("internet.js", function () { sinon.stub(faker.random, 'number').returns(1); sinon.spy(faker.name, 'firstName'); sinon.spy(faker.name, 'lastName'); - sinon.spy(faker.random, 'array_element'); + sinon.spy(faker.random, 'arrayElement'); var username = faker.internet.userName(); assert.ok(username); assert.ok(faker.name.firstName.called); assert.ok(faker.name.lastName.called); - assert.ok(faker.random.array_element.calledWith(['.', '_'])); + assert.ok(faker.random.arrayElement.calledWith(['.', '_'])); faker.random.number.restore(); faker.name.firstName.restore(); faker.name.lastName.restore(); - faker.random.array_element.restore(); + faker.random.arrayElement.restore(); }); }); -- cgit v1.2.3