Comparing version
{ | ||
"name": "chance", | ||
"version": "1.1.7", | ||
"version": "1.1.8", | ||
"main": "chance.js", | ||
@@ -5,0 +5,0 @@ "ignore": [ |
@@ -42,1 +42,8 @@ # phone | ||
``` | ||
For `us`, optionally specify an exampleNumber for a '555' area code. | ||
```js | ||
chance.phone({ country: 'us', exampleNumber: true }); | ||
=> '(555) 927-2152' | ||
``` |
@@ -14,1 +14,8 @@ # cpf | ||
``` | ||
Optionally omit punctuation: | ||
```js | ||
chance.cpf({ formatted: false }); | ||
=> '18641718397' | ||
``` |
@@ -6,3 +6,3 @@ # first | ||
chance.first() | ||
chance.first({ nationality: 'us' }) | ||
chance.first({ nationality: 'en' }) | ||
``` | ||
@@ -31,3 +31,3 @@ | ||
Note, currently support for nationality is limited to: `'us', 'it'`. | ||
Note, currently support for nationality is limited to: `'en', 'it', 'nl', 'fr'`. | ||
{ | ||
"name": "chance", | ||
"main": "./chance.js", | ||
"version": "1.1.7", | ||
"version": "1.1.8", | ||
"description": "Chance - Utility library to generate anything random", | ||
@@ -6,0 +6,0 @@ "homepage": "http://chancejs.com", |
@@ -420,2 +420,18 @@ import test from 'ava' | ||
test("phone() obeys exampleNumber option", (t) => { | ||
_.times(1000, () => { | ||
let phone = chance.phone({ exampleNumber: true }); | ||
t.true(_.isString(phone)); | ||
t.true(/^\(555\)?[\-. ]?([2-9][0-9]{2,2})[\-. ]?([0-9]{4,4})$/.test(phone)); | ||
}); | ||
}); | ||
test("phone() obeys formatted option and exampleNumber option", (t) => { | ||
_.times(1000, () => { | ||
let phone = chance.phone({ exampleNumber: true, formatted: false }); | ||
t.true(_.isString(phone)); | ||
t.true(/^555[2-9]\d{6,6}$/.test(phone)); | ||
}); | ||
}); | ||
test('phone() with uk option works', t => { | ||
@@ -422,0 +438,0 @@ t.true(_.isString(chance.phone({ country: 'uk' }))) |
@@ -243,2 +243,3 @@ import test from 'ava' | ||
t.true(_.isNumber(timezone.offset)) | ||
t.true(_.isArray(timezone.utc)) | ||
}) | ||
@@ -245,0 +246,0 @@ }) |
@@ -400,2 +400,23 @@ import test from 'ava' | ||
// chance.mac() | ||
test('mac() returns what looks like an MAC address (EUI-48)', t => { | ||
_.times(1000, () => { | ||
let mac = chance.mac() | ||
t.true(_.isString(mac)) | ||
t.is(mac.split(':').length, 6) | ||
t.true(/^[0-9a-f]{2}\:[0-9a-f]{2}\:[0-9a-f]{2}\:[0-9a-f]{2}\:[0-9a-f]{2}\:[0-9a-f]{2}$/.test(mac)) | ||
}) | ||
}) | ||
test('mac() uses delimiter option for MAC address', t => { | ||
_.times(1000, () => { | ||
const delimiter = ([':','-','.'])[Math.floor(Math.random() * 3)] | ||
let mac = chance.mac({ delimiter }) | ||
t.true(_.isString(mac)) | ||
t.is(mac.split(delimiter).length, 6) | ||
t.true(( | ||
new RegExp(`^${Array(6).fill('[0-9a-f]{2}').join(`\\${delimiter}`)}$`) | ||
).test(mac)) | ||
}) | ||
}) | ||
// chance.md5() | ||
@@ -402,0 +423,0 @@ test('md5() should create a hex-encoded MD5 hash of a random ASCII value when passed nothing', t => { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
1894323
0.23%20232
0.61%