faker
Advanced tools
Comparing version 2.1.4 to 2.1.5
{ | ||
"name": "faker", | ||
"main": "./build/build/faker.js", | ||
"version": "2.0.0", | ||
"homepage": "https://github.com/Marak/faker.js", | ||
@@ -6,0 +5,0 @@ "authors": [ |
@@ -44,3 +44,3 @@ /* | ||
var _definitions = { | ||
"name": ["first_name", "last_name", "prefix", "suffix"], | ||
"name": ["first_name", "last_name", "prefix", "suffix", "title"], | ||
"address": ["city_prefix", "city_suffix", "street_suffix", "county", "country", "state", "state_abbr"], | ||
@@ -74,2 +74,2 @@ "company": ["adjective", "noun", "descriptor", "bs_adjective", "bs_noun", "bs_verb"], | ||
}); | ||
}); | ||
}); |
@@ -36,2 +36,11 @@ var faker = require('../index'), | ||
protocol: function () { | ||
var protocols = ['http','https']; | ||
return faker.random.array_element(protocols); | ||
}, | ||
url: function () { | ||
return faker.internet.protocol() + '://' + faker.internet.domainName(); | ||
}, | ||
domainName: function () { | ||
@@ -38,0 +47,0 @@ return faker.internet.domainWord() + "." + faker.internet.domainSuffix(); |
@@ -16,2 +16,3 @@ var faker = require('../index'); | ||
exports['fr'] = require('./locales/fr.js'); | ||
exports['ge'] = require('./locales/ge.js'); | ||
exports['it'] = require('./locales/it.js'); | ||
@@ -28,3 +29,5 @@ exports['ja'] = require('./locales/ja.js'); | ||
exports['sv'] = require('./locales/sv.js'); | ||
exports['tr'] = require('./locales/tr.js'); | ||
exports['vi'] = require('./locales/vi.js'); | ||
exports['zh_CN'] = require('./locales/zh_CN.js'); | ||
exports['zh_CN'] = require('./locales/zh_CN.js'); | ||
exports['zh_TW'] = require('./locales/zh_TW.js'); |
@@ -11,8 +11,8 @@ var faker = require('../index'); | ||
if (rand === 0) { | ||
return faker.random.array_element(faker.locales[faker.locale].name.male_first_name) | ||
return faker.random.array_element(faker.locales[faker.locale].name.male_first_name); | ||
} else { | ||
return faker.random.array_element(faker.locales[faker.locale].name.female_first_name) | ||
return faker.random.array_element(faker.locales[faker.locale].name.female_first_name); | ||
} | ||
} | ||
return faker.random.array_element(faker.definitions.name.first_name) | ||
return faker.random.array_element(faker.definitions.name.first_name); | ||
}, | ||
@@ -56,4 +56,12 @@ | ||
title: function() { | ||
var descriptor = faker.random.array_element(faker.definitions.name.title.descriptor), | ||
level = faker.random.array_element(faker.definitions.name.title.level), | ||
job = faker.random.array_element(faker.definitions.name.title.job); | ||
return descriptor + " " + level + " " + job; | ||
} | ||
}; | ||
module.exports = _name; |
@@ -29,3 +29,3 @@ var mersenne = require('../vendor/mersenne'); | ||
var max = options.max; | ||
if (max > 0) { | ||
if (max >= 0) { | ||
max += options.precision; | ||
@@ -65,2 +65,6 @@ } | ||
return RFC4122_TEMPLATE.replace(/[xy]/g, replacePlaceholders); | ||
}, | ||
boolean: function () { | ||
return !!faker.random.number(1) | ||
} | ||
@@ -67,0 +71,0 @@ }; |
{ | ||
"name": "faker", | ||
"description": "Generate massive amounts of fake contextual data", | ||
"version": "2.1.4", | ||
"version": "2.1.5", | ||
"contributors": [ | ||
@@ -32,3 +32,4 @@ "Marak Squires <marak.squires@gmail.com>", | ||
}, | ||
"license": "MIT", | ||
"main": "index.js" | ||
} | ||
} |
@@ -76,2 +76,40 @@ if (typeof module !== 'undefined') { | ||
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 () { | ||
@@ -78,0 +116,0 @@ it("returns a random IP address with four parts", function () { |
@@ -70,2 +70,14 @@ if (typeof module !== 'undefined') { | ||
}); | ||
describe("title()", function () { | ||
it("returns a random title", function () { | ||
sinon.stub(faker.name, 'title').returns('Lead Solutions Supervisor'); | ||
var title = faker.name.title(); | ||
assert.equal(title, 'Lead Solutions Supervisor'); | ||
faker.name.title.restore(); | ||
}); | ||
}); | ||
}); |
@@ -17,3 +17,2 @@ if (typeof module !== 'undefined') { | ||
it("returns a random number given a maximum value as Object", function() { | ||
@@ -24,2 +23,12 @@ var options = { max: 10 }; | ||
it("returns a random number given a maximum value of 0", function() { | ||
var options = { max: 0 }; | ||
assert.ok(faker.random.number(options) === 0); | ||
}); | ||
it("returns a random number given a negative number minimum and maximum value of 0", function() { | ||
var options = { min: -100, max: 0 }; | ||
assert.ok(faker.random.number(options) <= options.max); | ||
}); | ||
it("returns a random number between a range", function() { | ||
@@ -67,2 +76,14 @@ var options = { min: 22, max: 33 }; | ||
describe('array_element', function() { | ||
it('returns a random element in the array', function() { | ||
var testArray = ['hello', 'to', 'you', 'my', 'friend']; | ||
assert.ok(testArray.indexOf(faker.random.array_element(testArray)) > -1); | ||
}); | ||
it('returns a random element in the array when there is only 1', function() { | ||
var testArray = ['hello']; | ||
assert.ok(testArray.indexOf(faker.random.array_element(testArray)) > -1); | ||
}); | ||
}); | ||
describe('UUID', function() { | ||
@@ -75,2 +96,9 @@ it('should generate a valid UUID', function() { | ||
}) | ||
describe('boolean', function() { | ||
it('should generate a boolean value', function() { | ||
var bool = faker.random.boolean(); | ||
assert.ok(typeof bool == 'boolean'); | ||
}); | ||
}); | ||
}); |
No License Found
License(Experimental) License information could not be found
Found 1 instance in 1 package
3867448
95
0
149849