aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMatthew Bergman <[email protected]>2013-03-18 10:12:01 -0700
committerMatthew Bergman <[email protected]>2013-03-18 10:12:01 -0700
commitd1ca803c370fa596db77f03f2c8424167e21b52d (patch)
tree4413b19a01afb38cb7b94b5b32d6bb7b08a6b7d9 /test
parent64e25936b14e662ddfe090a65caad630555486a6 (diff)
parentb9978821b6efdfcf0816969bfa9c44a3fe91dde0 (diff)
downloadfaker-d1ca803c370fa596db77f03f2c8424167e21b52d.tar.xz
faker-d1ca803c370fa596db77f03f2c8424167e21b52d.zip
Merge pull request #49 from fedosov/master
Cleaned JS according to .jshintrc, fixed #35
Diffstat (limited to 'test')
-rw-r--r--test/address.unit.js35
-rw-r--r--test/helpers.unit.js28
-rw-r--r--test/internet.unit.js12
3 files changed, 53 insertions, 22 deletions
diff --git a/test/address.unit.js b/test/address.unit.js
index edf0a7ac..a6e33c0b 100644
--- a/test/address.unit.js
+++ b/test/address.unit.js
@@ -164,12 +164,12 @@ describe("address.js", function () {
sinon.spy(Faker.random, 'array_element');
var address = Faker.Address.secondaryAddress();
-
+
var expected_array = [
'Apt. ###',
'Suite ###'
];
-
+
assert.ok(address);
assert.ok(Faker.random.array_element.calledWith(expected_array));
Faker.random.array_element.restore();
@@ -259,4 +259,35 @@ describe("address.js", function () {
});
});
});
+
+ describe("latitude()", function () {
+ it("returns random latitude", function () {
+ for (var i = 0; i < 100; i++) {
+ sinon.spy(Faker.random, 'number');
+ var latitude = Faker.Address.latitude();
+ assert.ok(typeof latitude === 'string');
+ var latitude_float = parseFloat(latitude);
+ assert.ok(latitude_float >= -90.0);
+ assert.ok(latitude_float <= 90.0);
+ assert.ok(Faker.random.number.called);
+ Faker.random.number.restore();
+ }
+ });
+ });
+
+ describe("longitude()", function () {
+ it("returns random longitude", function () {
+ for (var i = 0; i < 100; i++) {
+ sinon.spy(Faker.random, 'number');
+ var longitude = Faker.Address.longitude();
+ assert.ok(typeof longitude === 'string');
+ var longitude_float = parseFloat(longitude);
+ assert.ok(longitude_float >= -180.0);
+ assert.ok(longitude_float <= 180.0);
+ assert.ok(Faker.random.number.called);
+ Faker.random.number.restore();
+ }
+ });
+ });
+
});
diff --git a/test/helpers.unit.js b/test/helpers.unit.js
index 4c7ee808..3549099d 100644
--- a/test/helpers.unit.js
+++ b/test/helpers.unit.js
@@ -4,17 +4,17 @@ if (typeof module !== 'undefined') {
var Faker = require('../index');
}
-describe("helpers.js", function() {
- describe("replaceSymbolWithNumber()", function() {
- context("when no symbol passed in", function() {
- it("uses '#' by default", function() {
+describe("helpers.js", function () {
+ describe("replaceSymbolWithNumber()", function () {
+ context("when no symbol passed in", function () {
+ it("uses '#' by default", function () {
var num = Faker.Helpers.replaceSymbolWithNumber('#AB');
assert.ok(num.match(/\dAB/));
});
});
- context("when symbol passed in", function() {
- it("replaces that symbol with integers", function() {
+ context("when symbol passed in", function () {
+ it("replaces that symbol with integers", function () {
var num = Faker.Helpers.replaceSymbolWithNumber('#AB', 'A');
assert.ok(num.match(/#\dB/));
});
@@ -28,31 +28,31 @@ describe("helpers.js", function() {
});
});
- describe("createCard()", function() {
- it("returns an object", function() {
+ describe("createCard()", function () {
+ it("returns an object", function () {
var card = Faker.Helpers.createCard();
assert.ok(typeof card === 'object');
});
});
- describe("userCard()", function() {
- it("returns an object", function() {
+ describe("userCard()", function () {
+ it("returns an object", function () {
var card = Faker.Helpers.userCard();
assert.ok(typeof card === 'object');
});
});
// Make sure we keep this function for backward-compatibility.
- describe("randomNumber()", function() {
- it("returns an integer", function() {
+ describe("randomNumber()", function () {
+ it("returns an integer", function () {
var num = Faker.Helpers.randomNumber();
assert.ok(typeof num === 'number');
});
});
// Make sure we keep this function for backward-compatibility.
- describe("randomize()", function() {
- it("returns a random element from an array", function() {
+ describe("randomize()", function () {
+ it("returns a random element from an array", function () {
var arr = ['a', 'b', 'c'];
var elem = Faker.Helpers.randomize(arr);
assert.ok(elem);
diff --git a/test/internet.unit.js b/test/internet.unit.js
index 35b3a0f1..d7d823cf 100644
--- a/test/internet.unit.js
+++ b/test/internet.unit.js
@@ -49,8 +49,8 @@ describe("internet.js", function () {
});
});
- describe("domainName()", function() {
- it("returns a domainWord plus a random suffix", function() {
+ describe("domainName()", function () {
+ it("returns a domainWord plus a random suffix", function () {
sinon.stub(Faker.Internet, 'domainWord').returns('bar');
sinon.stub(Faker.random, 'domain_suffix').returns('net');
@@ -63,8 +63,8 @@ describe("internet.js", function () {
});
});
- describe("domainWord()", function() {
- it("returns a lower-case firstName", function() {
+ describe("domainWord()", function () {
+ it("returns a lower-case firstName", function () {
sinon.stub(Faker.random, 'first_name').returns('FOO');
var domain_word = Faker.Internet.domainWord();
@@ -75,8 +75,8 @@ describe("internet.js", function () {
});
});
- describe("ip()", function() {
- it("returns a random IP address with four parts", function() {
+ describe("ip()", function () {
+ it("returns a random IP address with four parts", function () {
var ip = Faker.Internet.ip();
var parts = ip.split('.');
assert.equal(parts.length, 4);