aboutsummaryrefslogtreecommitdiff
path: root/test/internet.unit.js
diff options
context:
space:
mode:
authorRonen Babayoff <[email protected]>2015-08-23 21:57:46 -0400
committerRonen Babayoff <[email protected]>2015-08-23 21:57:46 -0400
commit66996e280c9fbbbc2e7db376549f568be32ad5cd (patch)
treee93f412c4bceeb7ed0376e26113c9d31522af8b4 /test/internet.unit.js
parentcf0bd70d5fca9c0169414f5d2c16ca32431a3fd9 (diff)
parentd8f8108ac5dbec7e2b7ea9a23dd19aa42255e3fb (diff)
downloadfaker-66996e280c9fbbbc2e7db376549f568be32ad5cd.tar.xz
faker-66996e280c9fbbbc2e7db376549f568be32ad5cd.zip
Merge v3.0.1 into practicalmeteor:faker package branch
Diffstat (limited to 'test/internet.unit.js')
-rw-r--r--test/internet.unit.js50
1 files changed, 48 insertions, 2 deletions
diff --git a/test/internet.unit.js b/test/internet.unit.js
index 2fc0db10..9218a56e 100644
--- a/test/internet.unit.js
+++ b/test/internet.unit.js
@@ -33,17 +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.arrayElement.restore();
});
});
@@ -73,6 +74,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();
@@ -94,4 +133,11 @@ describe("internet.js", function () {
assert.ok(color.match(/^#[a-f0-9]{6}$/));
});
});
+
+ 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}$/));
+ });
+ });
});