Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chance

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chance - npm Package Compare versions

Comparing version 0.4.3 to 0.5.0

test/test.person.js

129

chance.js

@@ -1,2 +0,2 @@

// Chance.js 0.4.3
// Chance.js 0.5.0
// http://chancejs.com

@@ -223,2 +223,10 @@ // (c) 2013 Victor Quinn

Chance.prototype.mixin = function (obj) {
var chance = this;
for (var func_name in obj) {
Chance.prototype[func_name] = obj[func_name];
}
return this;
};
Chance.prototype.pick = function (arr, count) {

@@ -345,11 +353,51 @@ if (!count || count === 1) {

// -- Name --
// -- Person --
// Perhaps make this more intelligent at some point
Chance.prototype.age = function (options) {
options = initOptions(options);
var age;
switch (options.type) {
case 'child':
age = this.natural({min: 1, max: 12});
break;
case 'teen':
age = this.natural({min: 13, max: 19});
break;
case 'adult':
age = this.natural({min: 18, max: 120});
break;
case 'senior':
age = this.natural({min: 65, max: 120});
break;
default:
age = this.natural({min: 1, max: 120});
break;
}
return age;
};
Chance.prototype.birthday = function (options) {
options = initOptions(options, {
year: (new Date().getFullYear() - this.age(options))
});
return this.date(options);
};
var firstNames = ['Sophia', 'Emma', 'Isabella', 'Jacob', 'Mason', 'Ethan', 'Noah', 'Olivia', 'William', 'Liam', 'Jayden', 'Michael', 'Ava', 'Alexander', 'Aiden', 'Daniel', 'Matthew', 'Elijah', 'Emily', 'James', 'Anthony', 'Benjamin', 'Abigail', 'Joshua', 'Andrew', 'David', 'Joseph', 'Logan', 'Jackson', 'Mia', 'Christopher', 'Gabriel', 'Madison', 'Samuel', 'Ryan', 'Lucas', 'John', 'Nathan', 'Isaac', 'Dylan', 'Caleb', 'Elizabeth', 'Chloe', 'Christian', 'Landon', 'Jonathan', 'Carter', 'Ella', 'Luke', 'Owen', 'Brayden', 'Avery', 'Gavin', 'Wyatt', 'Addison', 'Isaiah', 'Aubrey', 'Henry', 'Eli', 'Hunter', 'Lily', 'Jack', 'Natalie', 'Evan', 'Sofia', 'Jordan', 'Nicholas', 'Tyler', 'Aaron', 'Charlotte', 'Zoey', 'Jeremiah', 'Julian', 'Cameron', 'Grace', 'Hannah', 'Amelia', 'Harper', 'Levi', 'Lillian', 'Brandon', 'Angel', 'Austin', 'Connor', 'Adrian', 'Robert', 'Samantha', 'Charles', 'Evelyn', 'Victoria', 'Thomas', 'Brooklyn', 'Sebastian', 'Zoe', 'Colton', 'Jaxon', 'Layla', 'Kevin', 'Zachary', 'Ayden', 'Dominic', 'Blake', 'Jose', 'Hailey', 'Oliver', 'Justin', 'Bentley', 'Leah', 'Jason', 'Chase', 'Ian', 'Kaylee', 'Anna', 'Aaliyah', 'Gabriella', 'Josiah', 'Allison', 'Parker', 'Xavier', 'Nevaeh', 'Alexis', 'Adam', 'Audrey', 'Cooper', 'Savannah', 'Sarah', 'Alyssa', 'Claire', 'Taylor', 'Riley', 'Camila', 'Nathaniel', 'Arianna', 'Ashley', 'Grayson', 'Jace', 'Brianna', 'Carson', 'Sophie', 'Peyton', 'Nolan', 'Tristan', 'Luis', 'Brody', 'Bella', 'Khloe', 'Genesis', 'Alexa', 'Juan', 'Hudson', 'Serenity', 'Kylie', 'Aubree', 'Scarlett', 'Bryson', 'Carlos', 'Stella', 'Maya', 'Easton', 'Katherine', 'Julia', 'Damian', 'Alex', 'Kayden', 'Ryder', 'Lucy', 'Madelyn', 'Jesus', 'Cole', 'Autumn', 'Makayla', 'Kayla', 'Mackenzie', 'Micah', 'Vincent', 'Max', 'Lauren', 'Jaxson', 'Gianna', 'Eric', 'Ariana', 'Asher', 'Hayden', 'Faith', 'Alexandra', 'Melanie', 'Sydney', 'Bailey', 'Caroline', 'Naomi', 'Morgan', 'Kennedy', 'Ellie', 'Jasmine', 'Eva', 'Skylar', 'Diego', 'Kimberly', 'Violet', 'Molly', 'Miles', 'Steven', 'Aria', 'Ivan', 'Jocelyn', 'Trinity', 'Elias', 'Aidan', 'Maxwell', 'London', 'Bryce', 'Lydia', 'Madeline', 'Antonio', 'Giovanni', 'Reagan', 'Timothy', 'Bryan', 'Piper', 'Andrea', 'Santiago', 'Annabelle', 'Maria', 'Colin', 'Richard', 'Braxton', 'Kaleb', 'Brooke', 'Kyle', 'Kaden', 'Preston', 'Payton', 'Miguel', 'Jonah', 'Paisley', 'Paige', 'Lincoln', 'Ruby', 'Nora', 'Riley', 'Mariah', 'Leo', 'Victor', 'Brady', 'Jeremy', 'Mateo', 'Brian', 'Jaden', 'Ashton', 'Patrick', 'Rylee', 'Declan', 'Lilly', 'Brielle', 'Sean', 'Joel', 'Gael', 'Sawyer', 'Alejandro', 'Jade', 'Marcus', 'Destiny', 'Leonardo', 'Jesse', 'Caden', 'Jake', 'Kaiden', 'Nicole', 'Mila', 'Wesley', 'Kendall', 'Liliana', 'Camden', 'Kaitlyn', 'Natalia', 'Sadie', 'Edward', 'Brantley', 'Jordyn', 'Roman', 'Vanessa', 'Mary', 'Mya', 'Penelope', 'Isabelle', 'Alice', 'Axel', 'Silas', 'Jude', 'Grant', 'Reese', 'Gabrielle', 'Hadley', 'Katelyn', 'Angelina', 'Rachel', 'Isabel', 'Eleanor', 'Cayden', 'Emmanuel', 'George', 'Clara', 'Brooklynn', 'Jessica', 'Maddox', 'Malachi', 'Bradley', 'Alan', 'Weston', 'Elena', 'Gage', 'Aliyah', 'Vivian', 'Laila', 'Sara', 'Amy', 'Devin', 'Eliana', 'Greyson', 'Lyla', 'Juliana', 'Kenneth', 'Mark', 'Oscar', 'Tanner', 'Rylan', 'Valeria', 'Adriana', 'Nicolas', 'Makenzie', 'Harrison', 'Elise', 'Mckenzie', 'Derek', 'Quinn', 'Delilah', 'Peyton', 'Ezra', 'Cora', 'Kylee', 'Tucker', 'Emmett', 'Avery', 'Cody', 'Rebecca', 'Gracie', 'Izabella', 'Calvin', 'Andres', 'Jorge', 'Abel', 'Paul', 'Abraham', 'Kai', 'Josephine', 'Alaina', 'Michelle', 'Jennifer', 'Collin', 'Theodore', 'Ezekiel', 'Eden', 'Omar', 'Jayce', 'Valentina', 'Conner', 'Bennett', 'Aurora', 'Catherine', 'Stephanie', 'Trevor', 'Valerie', 'Eduardo', 'Peter', 'Maximus', 'Jayla', 'Jaiden', 'Willow', 'Jameson', 'Seth', 'Daisy', 'Alana', 'Melody', 'Hazel', 'Kingston', 'Summer', 'Melissa', 'Javier', 'Margaret', 'Travis', 'Kinsley', 'Kinley', 'Garrett', 'Everett', 'Ariel', 'Lila', 'Graham', 'Giselle', 'Ryleigh', 'Xander', 'Haley', 'Julianna', 'Ivy', 'Alivia', 'Cristian', 'Brynn', 'Damien', 'Ryker', 'Griffin', 'Keira', 'Daniela', 'Aniyah', 'Angela', 'Kate', 'Londyn', 'Corbin', 'Myles', 'Hayden', 'Harmony', 'Adalyn', 'Luca', 'Zane', 'Francisco', 'Ricardo', 'Alexis', 'Stephen', 'Zayden', 'Megan', 'Allie', 'Gabriela', 'Iker', 'Drake', 'Alayna', 'Lukas', 'Presley', 'Charlie', 'Spencer', 'Zion', 'Erick', 'Jenna', 'Josue', 'Alexandria', 'Ashlyn', 'Adrianna', 'Jada', 'Jeffrey', 'Trenton', 'Fiona', 'Chance', 'Norah', 'Paxton', 'Elliot', 'Emery', 'Fernando', 'Maci', 'Miranda', 'Keegan', 'Landen', 'Ximena', 'Amaya', 'Manuel', 'Amir', 'Shane', 'Cecilia', 'Raymond', 'Andre', 'Ana', 'Shelby', 'Katie', 'Hope', 'Callie', 'Jordan', 'Luna', 'Leilani', 'Eliza', 'Mckenna', 'Angel', 'Genevieve', 'Makenna', 'Isla', 'Lola', 'Danielle', 'Chelsea', 'Leila', 'Tessa', 'Adelyn', 'Camille', 'Mikayla', 'Adeline', 'Adalynn', 'Sienna', 'Esther', 'Jacqueline', 'Emerson', 'Arabella', 'Maggie', 'Athena', 'Lucia', 'Lexi', 'Ayla'];
Chance.prototype.first = function () {
return this.capitalize(this.word());
return this.pick(firstNames);
};
Chance.prototype.gender = function () {
return this.pick(['Male', 'Female']);
};
var lastNames = ['Smith', 'Johnson', 'Williams', 'Jones', 'Brown', 'Davis', 'Miller', 'Wilson', 'Moore', 'Taylor', 'Anderson', 'Thomas', 'Jackson', 'White', 'Harris', 'Martin', 'Thompson', 'Garcia', 'Martinez', 'Robinson', 'Clark', 'Rodriguez', 'Lewis', 'Lee', 'Walker', 'Hall', 'Allen', 'Young', 'Hernandez', 'King', 'Wright', 'Lopez', 'Hill', 'Scott', 'Green', 'Adams', 'Baker', 'Gonzalez', 'Nelson', 'Carter', 'Mitchell', 'Perez', 'Roberts', 'Turner', 'Phillips', 'Campbell', 'Parker', 'Evans', 'Edwards', 'Collins', 'Stewart', 'Sanchez', 'Morris', 'Rogers', 'Reed', 'Cook', 'Morgan', 'Bell', 'Murphy', 'Bailey', 'Rivera', 'Cooper', 'Richardson', 'Cox', 'Howard', 'Ward', 'Torres', 'Peterson', 'Gray', 'Ramirez', 'James', 'Watson', 'Brooks', 'Kelly', 'Sanders', 'Price', 'Bennett', 'Wood', 'Barnes', 'Ross', 'Henderson', 'Coleman', 'Jenkins', 'Perry', 'Powell', 'Long', 'Patterson', 'Hughes', 'Flores', 'Washington', 'Butler', 'Simmons', 'Foster', 'Gonzales', 'Bryant', 'Alexander', 'Russell', 'Griffin', 'Diaz', 'Hayes', 'Myers', 'Ford', 'Hamilton', 'Graham', 'Sullivan', 'Wallace', 'Woods', 'Cole', 'West', 'Jordan', 'Owens', 'Reynolds', 'Fisher', 'Ellis', 'Harrison', 'Gibson', 'McDonald', 'Cruz', 'Marshall', 'Ortiz', 'Gomez', 'Murray', 'Freeman', 'Wells', 'Webb', 'Simpson', 'Stevens', 'Tucker', 'Porter', 'Hunter', 'Hicks', 'Crawford', 'Henry', 'Boyd', 'Mason', 'Morales', 'Kennedy', 'Warren', 'Dixon', 'Ramos', 'Reyes', 'Burns', 'Gordon', 'Shaw', 'Holmes', 'Rice', 'Robertson', 'Hunt', 'Black', 'Daniels', 'Palmer', 'Mills', 'Nichols', 'Grant', 'Knight', 'Ferguson', 'Rose', 'Stone', 'Hawkins', 'Dunn', 'Perkins', 'Hudson', 'Spencer', 'Gardner', 'Stephens', 'Payne', 'Pierce', 'Berry', 'Matthews', 'Arnold', 'Wagner', 'Willis', 'Ray', 'Watkins', 'Olson', 'Carroll', 'Duncan', 'Snyder', 'Hart', 'Cunningham', 'Bradley', 'Lane', 'Andrews', 'Ruiz', 'Harper', 'Fox', 'Riley', 'Armstrong', 'Carpenter', 'Weaver', 'Greene', 'Lawrence', 'Elliott', 'Chavez', 'Sims', 'Austin', 'Peters', 'Kelley', 'Franklin', 'Lawson', 'Fields', 'Gutierrez', 'Ryan', 'Schmidt', 'Carr', 'Vasquez', 'Castillo', 'Wheeler', 'Chapman', 'Oliver', 'Montgomery', 'Richards', 'Williamson', 'Johnston', 'Banks', 'Meyer', 'Bishop', 'McCoy', 'Howell', 'Alvarez', 'Morrison', 'Hansen', 'Fernandez', 'Garza', 'Harvey', 'Little', 'Burton', 'Stanley', 'Nguyen', 'George', 'Jacobs', 'Reid', 'Kim', 'Fuller', 'Lynch', 'Dean', 'Gilbert', 'Garrett', 'Romero', 'Welch', 'Larson', 'Frazier', 'Burke', 'Hanson', 'Day', 'Mendoza', 'Moreno', 'Bowman', 'Medina', 'Fowler', 'Brewer', 'Hoffman', 'Carlson', 'Silva', 'Pearson', 'Holland', 'Douglas', 'Fleming', 'Jensen', 'Vargas', 'Byrd', 'Davidson', 'Hopkins', 'May', 'Terry', 'Herrera', 'Wade', 'Soto', 'Walters', 'Curtis', 'Neal', 'Caldwell', 'Lowe', 'Jennings', 'Barnett', 'Graves', 'Jimenez', 'Horton', 'Shelton', 'Barrett', 'Obrien', 'Castro', 'Sutton', 'Gregory', 'McKinney', 'Lucas', 'Miles', 'Craig', 'Rodriquez', 'Chambers', 'Holt', 'Lambert', 'Fletcher', 'Watts', 'Bates', 'Hale', 'Rhodes', 'Pena', 'Beck', 'Newman', 'Haynes', 'McDaniel', 'Mendez', 'Bush', 'Vaughn', 'Parks', 'Dawson', 'Santiago', 'Norris', 'Hardy', 'Love', 'Steele', 'Curry', 'Powers', 'Schultz', 'Barker', 'Guzman', 'Page', 'Munoz', 'Ball', 'Keller', 'Chandler', 'Weber', 'Leonard', 'Walsh', 'Lyons', 'Ramsey', 'Wolfe', 'Schneider', 'Mullins', 'Benson', 'Sharp', 'Bowen', 'Daniel', 'Barber', 'Cummings', 'Hines', 'Baldwin', 'Griffith', 'Valdez', 'Hubbard', 'Salazar', 'Reeves', 'Warner', 'Stevenson', 'Burgess', 'Santos', 'Tate', 'Cross', 'Garner', 'Mann', 'Mack', 'Moss', 'Thornton', 'Dennis', 'McGee', 'Farmer', 'Delgado', 'Aguilar', 'Vega', 'Glover', 'Manning', 'Cohen', 'Harmon', 'Rodgers', 'Robbins', 'Newton', 'Todd', 'Blair', 'Higgins', 'Ingram', 'Reese', 'Cannon', 'Strickland', 'Townsend', 'Potter', 'Goodwin', 'Walton', 'Rowe', 'Hampton', 'Ortega', 'Patton', 'Swanson', 'Joseph', 'Francis', 'Goodman', 'Maldonado', 'Yates', 'Becker', 'Erickson', 'Hodges', 'Rios', 'Conner', 'Adkins', 'Webster', 'Norman', 'Malone', 'Hammond', 'Flowers', 'Cobb', 'Moody', 'Quinn', 'Blake', 'Maxwell', 'Pope', 'Floyd', 'Osborne', 'Paul', 'McCarthy', 'Guerrero', 'Lindsey', 'Estrada', 'Sandoval', 'Gibbs', 'Tyler', 'Gross', 'Fitzgerald', 'Stokes', 'Doyle', 'Sherman', 'Saunders', 'Wise', 'Colon', 'Gill', 'Alvarado', 'Greer', 'Padilla', 'Simon', 'Waters', 'Nunez', 'Ballard', 'Schwartz', 'McBride', 'Houston', 'Christensen', 'Klein', 'Pratt', 'Briggs', 'Parsons', 'McLaughlin', 'Zimmerman', 'French', 'Buchanan', 'Moran', 'Copeland', 'Roy', 'Pittman', 'Brady', 'McCormick', 'Holloway', 'Brock', 'Poole', 'Frank', 'Logan', 'Owen', 'Bass', 'Marsh', 'Drake', 'Wong', 'Jefferson', 'Park', 'Morton', 'Abbott', 'Sparks', 'Patrick', 'Norton', 'Huff', 'Clayton', 'Massey', 'Lloyd', 'Figueroa', 'Carson', 'Bowers', 'Roberson', 'Barton', 'Tran', 'Lamb', 'Harrington', 'Casey', 'Boone', 'Cortez', 'Clarke', 'Mathis', 'Singleton', 'Wilkins', 'Cain', 'Bryan', 'Underwood', 'Hogan', 'McKenzie', 'Collier', 'Luna', 'Phelps', 'McGuire', 'Allison', 'Bridges', 'Wilkerson', 'Nash', 'Summers', 'Atkins'];
Chance.prototype.last = function () {
return this.capitalize(this.word());
return this.pick(lastNames);
};

@@ -365,3 +413,3 @@

if (options.middle) {
name = first + ' ' + this.capitalize(this.word()) + ' ' + last;
name = first + ' ' + this.first() + ' ' + last;
} else if (options.middle_initial) {

@@ -401,3 +449,3 @@ name = first + ' ' + this.character({alpha: true, casing: 'upper'}) + '. ' + last;

// -- End Name --
// -- End Person --

@@ -444,5 +492,9 @@ // -- Web --

Chance.prototype.fbid = function () {
return '10000' + this.natural({max: 100000000000}).toString();
return parseInt('10000' + this.natural({max: 100000000000}), 10);
};
Chance.prototype.hashtag = function () {
return '#' + this.word();
};
Chance.prototype.ip = function () {

@@ -466,2 +518,6 @@ // Todo: This could return some reserved IPs. See http://vq.io/137dgYy

Chance.prototype.klout = function () {
return this.natural({min: 1, max: 99});
};
Chance.prototype.tlds = function () {

@@ -741,2 +797,32 @@ return ['com', 'org', 'edu', 'gov', 'co.uk', 'net', 'io'];

Chance.prototype.date = function (options) {
var year = parseInt(chance.year(), 10),
m = chance.month({raw: true}),
// Necessary because Date() 0-indexes month but not day or year
// for some reason.
month = m.numeric - 1,
day = chance.natural({min: 1, max: m.days}),
date;
options = initOptions(options, {
year: year,
month: month,
day: day,
american: true,
string: false
});
date = new Date(options.year, options.month, options.day);
if (options.american) {
// Adding 1 to the month is necessary because Date() 0-indexes
// months but not day for some odd reason.
date_string = (date.getMonth() + 1) + '/' + date.getDate() + '/' + date.getFullYear();
} else {
date_string = date.getDate() + '/' + (date.getMonth() + 1) + '/' + date.getFullYear();
}
return options.string ? date_string : date;
};
Chance.prototype.hour = function (options) {

@@ -760,14 +846,15 @@ options = initOptions(options);

return [
{name: 'January', short_name: 'Jan', numeric: '01'},
{name: 'February', short_name: 'Feb', numeric: '02'},
{name: 'March', short_name: 'Mar', numeric: '03'},
{name: 'April', short_name: 'Apr', numeric: '04'},
{name: 'May', short_name: 'May', numeric: '05'},
{name: 'June', short_name: 'Jun', numeric: '06'},
{name: 'July', short_name: 'Jul', numeric: '07'},
{name: 'August', short_name: 'Aug', numeric: '08'},
{name: 'September', short_name: 'Sep', numeric: '09'},
{name: 'October', short_name: 'Oct', numeric: '10'},
{name: 'November', short_name: 'Nov', numeric: '11'},
{name: 'December', short_name: 'Dec', numeric: '12'}
{name: 'January', short_name: 'Jan', numeric: '01', days: 31},
// Not messing with leap years...
{name: 'February', short_name: 'Feb', numeric: '02', days: 28},
{name: 'March', short_name: 'Mar', numeric: '03', days: 31},
{name: 'April', short_name: 'Apr', numeric: '04', days: 30},
{name: 'May', short_name: 'May', numeric: '05', days: 31},
{name: 'June', short_name: 'Jun', numeric: '06', days: 30},
{name: 'July', short_name: 'Jul', numeric: '07', days: 31},
{name: 'August', short_name: 'Aug', numeric: '08', days: 31},
{name: 'September', short_name: 'Sep', numeric: '09', days: 30},
{name: 'October', short_name: 'Oct', numeric: '10', days: 31},
{name: 'November', short_name: 'Nov', numeric: '11', days: 30},
{name: 'December', short_name: 'Dec', numeric: '12', days: 31}
];

@@ -994,3 +1081,3 @@ };

Chance.prototype.VERSION = "0.4.3";
Chance.prototype.VERSION = "0.5.0";

@@ -997,0 +1084,0 @@ // Mersenne Twister from https://gist.github.com/banksean/300494

16

package.json
{
"name": "chance",
"main": "./chance.js",
"version": "0.4.3",
"version": "0.5.0",
"description": "Chance - Utility library to generate anything random",

@@ -23,9 +23,8 @@ "homepage": "http://chancejs.com",

"chai": "1.5",
"grunt": "*",
"grunt": "0.4.1",
"grunt-contrib-jshint": "~0.1.1",
"grunt-mocha-phantomjs": "*",
"grunt-contrib-uglify": "*",
"grunt-contrib-watch": "*",
"grunt-shell": "*",
"jslint": "*",
"grunt-mocha-phantomjs": "0.3.0",
"grunt-contrib-uglify": "0.2.4",
"grunt-contrib-watch": "0.5.3",
"grunt-shell": "0.3.1",
"mocha": "1.8",

@@ -36,3 +35,3 @@ "mocha-phantomjs": "2.0.3",

"uglify-js": "1.2.6",
"underscore": "*"
"underscore": "1.5.2"
},

@@ -43,2 +42,3 @@ "scripts": {

"keywords": [
"chance",
"random",

@@ -45,0 +45,0 @@ "generator",

@@ -83,22 +83,24 @@ # Chance

project : chancejs
repo age : 6 weeks
active : 35 days
commits : 186
files : 19
repo age : 4 months
active : 40 days
commits : 215
files : 18
authors :
140 Victor Quinn 75.3%
11 Tim Petricola 5.9%
11 davmillar 5.9%
5 Matt Klaber 2.7%
5 Michael Cordingley 2.7%
3 qjcg 1.6%
2 dhilipsiva 1.1%
2 Kevin Garnett 1.1%
2 path411 1.1%
2 Andreas Koeberle 1.1%
1 Richard Anaya 0.5%
1 leesei 0.5%
1 Ryan Tenney 0.5%
167 Victor Quinn 77.7%
11 davmillar 5.1%
11 Tim Petricola 5.1%
5 Michael Cordingley 2.3%
5 Matt Klaber 2.3%
3 qjcg 1.4%
2 dhilipsiva 0.9%
2 Andreas Koeberle 0.9%
2 path411 0.9%
2 Kevin Garnett 0.9%
1 Ryan Tenney 0.5%
1 Doug Lawrence 0.5%
1 Richard Anaya 0.5%
1 Adam Krebs 0.5%
1 leesei 0.5%
```
This project is licensed under the [MIT License](http://en.wikipedia.org/wiki/MIT_License) so feel free to hack away :)

@@ -27,3 +27,3 @@ require.config({

var assert = chai.assert;
require(['test.address', 'test.basic', 'test.finance', 'test.helpers', 'test.misc', 'test.name', 'test.text', 'test.time', 'test.web'], function () {
require(['test.address', 'test.basic', 'test.finance', 'test.helpers', 'test.misc', 'test.person', 'test.text', 'test.time', 'test.web'], function () {
mocha.reporter('html');

@@ -30,0 +30,0 @@

@@ -118,2 +118,49 @@ define(['Chance', 'mocha', 'chai', 'underscore'], function (Chance, mocha, chai, _) {

});
describe("Mixin", function () {
var chance = new Chance();
it("exists", function () {
expect(chance).to.have.property('mixin');
});
it("works with a simple function", function () {
chance.mixin({
'user': function () {
return {
first: chance.first(),
last: chance.last(),
email: chance.email()
};
}
});
expect(chance).to.have.property('user');
_(1000).times(function () {
expect(chance.user()).to.be.ok;
expect(chance.user()).to.have.property('first');
});
});
it("multiple mixins work, can call previously defined mixins", function () {
chance.mixin({
'user': function () {
return {
first: chance.first(),
last: chance.last(),
email: chance.email()
};
},
'social_user': function () {
var user = chance.user();
user.network = chance.pick(['facebook', 'twitter']);
return user;
}
});
expect(chance).to.have.property('social_user');
_(1000).times(function () {
expect(chance.social_user()).to.be.ok;
expect(chance.social_user()).to.have.property('first');
expect(chance.social_user()).to.have.property('network');
});
});
});
});

@@ -5,4 +5,35 @@ define(['Chance', 'mocha', 'chai', 'underscore'], function (Chance, mocha, chai, _) {

describe("Time", function () {
var hour, minute, time, timestamp, month, year, chance = new Chance();
var date, hour, minute, time, timestamp, month, year, chance = new Chance();
it("date() returns a date", function () {
_(1000).times(function () {
date = chance.date();
expect(date).to.be.a('Date');
expect(date.getTime()).to.be.ok;
});
});
it("date() can have some defaults provided and obeys them", function () {
_(1000).times(function () {
date = chance.date({year: 1983});
expect(date).to.be.a('Date');
expect(date.getFullYear()).to.equal(1983);
date = chance.date({month: 0});
expect(date).to.be.a('Date');
expect(date.getMonth()).to.equal(0);
date = chance.date({day: 21});
expect(date).to.be.a('Date');
expect(date.getDate()).to.equal(21);
});
});
it("date() can return a string date", function () {
_(1000).times(function () {
expect(chance.date({string: true})).to.be.a('string');
expect(chance.date({string: true})).to.match(/^[0-9][0-9]?\/[0-9][0-9]?\/[0-9]{4}/m);
});
});
it("hour() returns a hour", function () {

@@ -9,0 +40,0 @@ _(1000).times(function () {

@@ -5,3 +5,3 @@ define(['Chance', 'mocha', 'chai', 'underscore'], function (Chance, mocha, chai, _) {

describe("Web", function () {
var tld, domain, email, ip, ipv6, twitter, chance = new Chance();
var tld, domain, email, hashtag, ip, ipv6, twitter, chance = new Chance();

@@ -50,6 +50,14 @@ it("tld() returns a tld", function () {

_(1000).times(function () {
expect(chance.fbid()).to.be.a('string');
expect(chance.fbid()).to.be.a('number');
});
});
it("hashtag() returns what looks like a hashtag", function () {
_(1000).times(function () {
hashtag = chance.hashtag();
expect(hashtag).to.be.a('string');
expect(hashtag).to.match(/^\#\w+$/m);
});
});
it("ip() returns what looks like an IP address", function () {

@@ -71,2 +79,9 @@ _(1000).times(function () {

it("klout() returns what looks like a legit Klout score", function () {
_(1000).times(function () {
expect(chance.klout()).to.be.a('number');
expect(chance.klout()).to.be.within(1, 100);
});
});
it("twitter() returns what looks like a Twitter handle", function () {

@@ -73,0 +88,0 @@ _(1000).times(function () {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc