Comparing version 1.0.3 to 1.0.4
{ | ||
"name": "chance", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"main": "chance.js", | ||
@@ -5,0 +5,0 @@ "ignore": [ |
@@ -5,3 +5,3 @@ { | ||
"description": "Minimalist generator of random strings, numbers, etc.", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"keywords": ["chance", "random", "generator", "test"], | ||
@@ -8,0 +8,0 @@ "main": "chance.js", |
{ | ||
"name": "chance", | ||
"main": "./chance.js", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Chance - Utility library to generate anything random", | ||
@@ -6,0 +6,0 @@ "homepage": "http://chancejs.com", |
124
README.md
@@ -139,79 +139,87 @@ # Chance | ||
``` | ||
project : chancejs | ||
repo age : 2 years, 10 months | ||
active : 184 days | ||
commits : 654 | ||
project : chancejs | ||
repo age : 3 years, 1 month | ||
active : 195 days | ||
commits : 682 | ||
files : 28 | ||
authors : | ||
434 Victor Quinn 66.4% | ||
26 Oliver Salzburg 4.0% | ||
13 Tim Petricola 2.0% | ||
446 Victor Quinn 65.4% | ||
26 Oliver Salzburg 3.8% | ||
13 Tim Petricola 1.9% | ||
12 Alex DiLiberto 1.8% | ||
11 Matteo Fogli 1.7% | ||
11 davmillar 1.7% | ||
7 Jan Tojnar 1.1% | ||
7 AminaG 1.1% | ||
11 davmillar 1.6% | ||
11 Matteo Fogli 1.6% | ||
7 Jan Tojnar 1.0% | ||
7 AminaG 1.0% | ||
7 jonbev 1.0% | ||
6 Matt Klaber 0.9% | ||
6 Patrick Mowrer 0.9% | ||
5 Michael Cordingley 0.8% | ||
5 Michael Cordingley 0.7% | ||
4 Geoff Russel 0.6% | ||
4 anio 0.6% | ||
4 Geoff Russel 0.6% | ||
4 Chris Villarreal 0.6% | ||
4 leesei 0.6% | ||
4 Kevin Garnett 0.6% | ||
4 Abhijeet Pawar 0.6% | ||
4 Avishaan 0.6% | ||
4 spayton 0.6% | ||
4 leesei 0.6% | ||
4 Chris Villarreal 0.6% | ||
4 Kevin Garnett 0.6% | ||
4 Dominic Barnes 0.6% | ||
3 Alexandr Lozovyuk 0.5% | ||
3 Nicholas Johnson 0.5% | ||
3 qjcg 0.5% | ||
3 Nate Clark 0.5% | ||
4 Avishaan 0.6% | ||
3 Nicholas Johnson 0.4% | ||
3 Nate Clark 0.4% | ||
3 qjcg 0.4% | ||
3 Alexandr Lozovyuk 0.4% | ||
2 somejeff 0.3% | ||
2 Rafael Andrade de Oliveira 0.3% | ||
2 Kris Van Houten 0.3% | ||
2 vird 0.3% | ||
2 xshyamx 0.3% | ||
2 Adam Krebs 0.3% | ||
2 Andreas Koeberle 0.3% | ||
2 Daniel Biedma 0.3% | ||
2 Franco Victorio 0.3% | ||
2 Iskren Chernev 0.3% | ||
2 Kris Van Houten 0.3% | ||
2 The Usual Coder 0.3% | ||
2 Michael Sakaluk 0.3% | ||
2 Mihail Petrov 0.3% | ||
2 Nathan MacInnes 0.3% | ||
2 Ng Patrick 0.3% | ||
2 Ng Patrick 0.3% | ||
2 dhilipsiva 0.3% | ||
2 Stefan Penner 0.3% | ||
2 Iskren Chernev 0.3% | ||
2 Cube ix 0.3% | ||
2 Daniel Biedma 0.3% | ||
2 Pascal Borreli 0.3% | ||
2 Rafael Andrade de Oliveira 0.3% | ||
2 Andreas Koeberle 0.3% | ||
2 SeeSchloss 0.3% | ||
2 Stefan Penner 0.3% | ||
2 The Usual Coder 0.3% | ||
2 dhilipsiva 0.3% | ||
2 max4ever 0.3% | ||
2 path411 0.3% | ||
2 shyam 0.3% | ||
2 somejeff 0.3% | ||
2 vird 0.3% | ||
1 Billy Moon 0.2% | ||
1 Eu Rafa 0.2% | ||
1 Tomasz Ducin 0.2% | ||
1 Drew Brokke 0.2% | ||
1 Winker Xiao 0.2% | ||
1 afc163 0.2% | ||
1 Doug Lawrence 0.2% | ||
1 Danny Yates 0.2% | ||
1 ddunning 0.2% | ||
1 tsc 0.2% | ||
1 flaviolivolsi 0.2% | ||
1 flrent 0.2% | ||
1 kiran 0.2% | ||
1 kkroner 0.2% | ||
1 Brian.Barnett 0.2% | ||
1 Matt Altermatt 0.2% | ||
1 Joshua Bemenderfer 0.2% | ||
1 lkptrzk 0.2% | ||
1 Johannes Stein 0.2% | ||
1 Piotrek Dąbrowski 0.2% | ||
1 mamrehn 0.2% | ||
1 Richard Anaya 0.2% | ||
1 Ryan Tenney 0.2% | ||
1 Samuel Greene 0.2% | ||
1 Adam Pointer 0.2% | ||
1 Bitdeli Chef 0.2% | ||
1 mamrehn 0.1% | ||
1 Adam Pointer 0.1% | ||
1 Amit Merchant 0.1% | ||
1 Billy Moon 0.1% | ||
1 Bitdeli Chef 0.1% | ||
1 Brian.Barnett 0.1% | ||
1 Danny Yates 0.1% | ||
1 Doug Lawrence 0.1% | ||
1 Drew Brokke 0.1% | ||
1 Eu Rafa 0.1% | ||
1 Guillaume Bourel 0.1% | ||
1 Hilke Heremans 0.1% | ||
1 Jean Paulo de Almeida 0.1% | ||
1 Johannes Stein 0.1% | ||
1 Joshua Bemenderfer 0.1% | ||
1 Matt Altermatt 0.1% | ||
1 Piotrek Dąbrowski 0.1% | ||
1 Richard Anaya 0.1% | ||
1 Ryan Tenney 0.1% | ||
1 Samuel Greene 0.1% | ||
1 Thomas Rueckstiess 0.1% | ||
1 Tomasz Ducin 0.1% | ||
1 Winker Xiao 0.1% | ||
1 afc163 0.1% | ||
1 ddunning 0.1% | ||
1 flaviolivolsi 0.1% | ||
1 flrent 0.1% | ||
1 kiran 0.1% | ||
1 kkroner 0.1% | ||
1 lkptrzk 0.1% | ||
1 tsc 0.1% | ||
``` | ||
@@ -218,0 +226,0 @@ |
@@ -107,2 +107,9 @@ /// <reference path="../chance.js" /> | ||
it("state({country: 'uk', full: true}) returns a random (long) state name", function () { | ||
_(1000).times(function () { | ||
state = chance.state({country: 'uk', full: true}); | ||
expect(state.length).to.be.above(2); | ||
}); | ||
}); | ||
it("states() returns all 50 US States and DC", function () { | ||
@@ -139,2 +146,6 @@ expect(chance.states()).to.have.length(51); | ||
}); | ||
it("states({country: 'uk') returns 90 UK Conties", function () { | ||
expect(chance.states({country: 'uk'})).to.have.length(90); | ||
}); | ||
}); | ||
@@ -170,2 +181,20 @@ | ||
describe("Counties", function () { | ||
it("provinces() returns an array of counties", function () { | ||
expect(chance.counties()).to.be.an('array'); | ||
}); | ||
it("counties({full: true}) returns a random (long) county name", function () { | ||
_(1000).times(function () { | ||
expect(chance.counties({full: true})).to.have.length.above(2); | ||
}); | ||
}); | ||
it("province({ country: 'uk', full: true}) returns a random (long) county name", function () { | ||
_(1000).times(function () { | ||
expect(chance.counties({country: 'uk', full: true})).to.have.length.above(2); | ||
}); | ||
}); | ||
}); | ||
describe("Address", function () { | ||
@@ -172,0 +201,0 @@ it("address() returns a string", function () { |
@@ -7,3 +7,13 @@ /// <reference path="../chance.js" /> | ||
describe("Person", function () { | ||
var name, first, last, nationality, prefix, suffix, ssn, chance = new Chance(); | ||
var name, first, last, nationality, prefix, suffix, ssn, chance = new Chance(), | ||
CHILD_AGE_MIN = 0, | ||
CHILD_AGE_MAX = 12, | ||
TEEN_AGE_MIN = 13, | ||
TEEN_AGE_MAX = 19, | ||
ADULT_AGE_MIN = 18, | ||
ADULT_AGE_MAX = 65, | ||
SENIOR_AGE_MIN = 65, | ||
SENIOR_AGE_MAX = 100, | ||
AGE_MIN = 0, | ||
AGE_MAX = 100; | ||
@@ -14,3 +24,3 @@ describe("age()", function () { | ||
expect(chance.age()).to.be.a('number'); | ||
expect(chance.age()).to.be.within(1, 100); | ||
expect(chance.age()).to.be.within(AGE_MIN, AGE_MAX); | ||
}); | ||
@@ -26,3 +36,3 @@ }); | ||
expect(age).to.be.a('number'); | ||
expect(age).to.be.within(1, 12); | ||
expect(age).to.be.within(CHILD_AGE_MIN, CHILD_AGE_MAX); | ||
}); | ||
@@ -35,3 +45,3 @@ }); | ||
expect(age).to.be.a('number'); | ||
expect(age).to.be.within(13, 19); | ||
expect(age).to.be.within(TEEN_AGE_MIN, TEEN_AGE_MAX); | ||
}); | ||
@@ -44,3 +54,3 @@ }); | ||
expect(age).to.be.a('number'); | ||
expect(age).to.be.within(18, 65); | ||
expect(age).to.be.within(ADULT_AGE_MIN, ADULT_AGE_MAX); | ||
}); | ||
@@ -53,3 +63,3 @@ }); | ||
expect(age).to.be.a('number'); | ||
expect(age).to.be.within(65, 100); | ||
expect(age).to.be.within(SENIOR_AGE_MIN, SENIOR_AGE_MAX); | ||
}); | ||
@@ -61,4 +71,4 @@ }); | ||
_(1000).times(function () { | ||
expect(chance.age({type: 'child'})).to.be.within(1, 13); | ||
expect(chance.age({type: 'senior'})).to.be.within(65, 120); | ||
expect(chance.age({type: 'child'})).to.be.within(CHILD_AGE_MIN, CHILD_AGE_MAX); | ||
expect(chance.age({type: 'senior'})).to.be.within(SENIOR_AGE_MIN, SENIOR_AGE_MAX); | ||
}); | ||
@@ -72,3 +82,3 @@ }); | ||
expect(chance.birthday()).to.be.a('Date'); | ||
expect(chance.birthday().getFullYear()).to.be.within((new Date().getFullYear() - 120), (new Date().getFullYear())); | ||
expect(chance.birthday().getFullYear()).to.be.within((new Date().getFullYear() - AGE_MAX), (new Date().getFullYear())); | ||
}); | ||
@@ -90,6 +100,50 @@ }); | ||
it("can have an age range specified", function () { | ||
_(1000).times(function () { | ||
expect(chance.birthday({type: 'child'}).getFullYear()).to.be.within((new Date().getFullYear() - 13), (new Date().getFullYear())); | ||
describe("can have an age range specified", function () { | ||
var currentYear = new Date().getFullYear(); | ||
it("for an adult", function () { | ||
_(1000).times(function () { | ||
// "Age" is the floor of someone's decimal age - if you are 65.75 years old, you are considered "65" | ||
// Someone who is "65" was born between 66 and 65 years ago | ||
var min = (new Date().setFullYear(currentYear - ADULT_AGE_MAX - 1)); | ||
var max = (new Date().setFullYear(currentYear - ADULT_AGE_MIN)); | ||
expect(chance.birthday({ | ||
type: 'adult' | ||
}).getTime()).to.be.within(min, max); | ||
}); | ||
}); | ||
it("for a teen", function () { | ||
_(1000).times(function () { | ||
var min = (new Date().setFullYear(currentYear - TEEN_AGE_MAX - 1)); | ||
var max = (new Date().setFullYear(currentYear - TEEN_AGE_MIN)); | ||
expect(chance.birthday({ | ||
type: 'teen' | ||
}).getTime()).to.be.within(min, max); | ||
}); | ||
}); | ||
it("for a child", function () { | ||
_(1000).times(function () { | ||
var min = (new Date().setFullYear(currentYear - CHILD_AGE_MAX - 1)); | ||
var max = (new Date().setFullYear(currentYear - CHILD_AGE_MIN)); | ||
expect(chance.birthday({ | ||
type: 'child' | ||
}).getTime()).to.be.within(min, max); | ||
}); | ||
}); | ||
it("for a senior", function () { | ||
_(1000).times(function () { | ||
var min = (new Date().setFullYear(currentYear - SENIOR_AGE_MAX - 1)); | ||
var max = (new Date().setFullYear(currentYear - SENIOR_AGE_MIN)); | ||
expect(chance.birthday({ | ||
type: 'senior' | ||
}).getTime()).to.be.within(min, max); | ||
}); | ||
}); | ||
}); | ||
@@ -104,2 +158,9 @@ }); | ||
}); | ||
describe("extra genders", function () { | ||
it("returns a random gender", function () { | ||
_(1000).times(function() { | ||
expect(chance.gender({extraGenders: ['Unknown', 'Transgender']})).to.be.match(/(Male|Female|Unknown|Transgender)/); | ||
}); | ||
}); | ||
}); | ||
}); | ||
@@ -106,0 +167,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
597076
8277
243