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 1.0.1 to 1.0.2

test/test.company.js

2

bower.json
{
"name": "chance",
"version": "1.0.1",
"version": "1.0.2",
"main": "chance.js",

@@ -5,0 +5,0 @@ "ignore": [

@@ -5,3 +5,3 @@ {

"description": "Minimalist generator of random strings, numbers, etc.",
"version": "1.0.1",
"version": "1.0.2",
"keywords": ["chance", "random", "generator", "test"],

@@ -8,0 +8,0 @@ "main": "chance.js",

{
"name": "chance",
"main": "./chance.js",
"version": "1.0.1",
"version": "1.0.2",
"description": "Chance - Utility library to generate anything random",

@@ -6,0 +6,0 @@ "homepage": "http://chancejs.com",

@@ -57,2 +57,3 @@ # Chance

</script>
```

@@ -124,2 +125,3 @@ ### npm

* [Fake JSON Schema](https://github.com/pateketrueke/json-schema-faker/) - Use chance generators to populate JSON Schema samples.
* [Mocker Data Generator](https://github.com/danibram/mocker-data-generator/) - Minimal JSON data generator.

@@ -126,0 +128,0 @@ *Know a library that uses Chance that isn't here? Update the README and submit a PR!*

@@ -86,2 +86,9 @@ /// <reference path="../chance.js" />

it("state( { country: 'it' } ) returns a random (short) state name", function () {
_(1000).times(function () {
state = chance.state( { country: 'it' } );
expect(state.length).to.equal(3);
});
});
it("state({full: true}) returns a random (long) state name", function () {

@@ -94,2 +101,9 @@ _(1000).times(function () {

it("state({country: 'it', full: true}) returns a random (long) state name", function () {
_(1000).times(function () {
state = chance.state({country: 'it', full: true});
expect(state.length).to.be.above(2);
});
});
it("states() returns all 50 US States and DC", function () {

@@ -122,2 +136,6 @@ expect(chance.states()).to.have.length(51);

});
it("states({country: 'it') returns 20 Italian Regions", function () {
expect(chance.states({country: 'it'})).to.have.length(20);
});
});

@@ -130,2 +148,6 @@

it("provinces() to support internationalization", function () {
expect(chance.provinces()).not.to.equal(chance.provinces( { country: 'it' } ));
});
it("province() returns a random (short) province name", function () {

@@ -142,2 +164,8 @@ _(1000).times(function () {

});
it("province({ country: 'it', full: true}) returns a random (long) province name", function () {
_(1000).times(function () {
expect(chance.province({country: 'it', full: true})).to.have.length.above(2);
});
});
});

@@ -144,0 +172,0 @@

@@ -208,4 +208,7 @@ /// <reference path="../chance.js" />

var expMonth = parseInt(chance.exp_month({ future: true }), 10);
expect(expMonth).to.be.above(nowMonth);
if(nowMonth !== 12) {
expect(expMonth).to.be.above(nowMonth);
} else {
expect(expMonth).to.be.within(1, 12);
}
});

@@ -212,0 +215,0 @@ });

@@ -289,2 +289,10 @@ /// <reference path="../chance.js" />

it("works properly with options", function () {
_(500).times(function () {
var arr = chance.unique(chance.date, 20, { year: 2016 });
expect(arr).to.be.an('array');
expect(_.uniq(arr).length).to.equal(20);
});
});
it("throws a RangeError when num is likely out of range", function () {

@@ -291,0 +299,0 @@ expect(function () {

@@ -36,2 +36,47 @@ /// <reference path="../chance.js" />

});
describe("Italian Specific", function (){
var vat;
describe("Luhn Check on Italian VAT number", function () {
it("checks if number passes Luhn algorithm", function () {
expect(chance.luhn_check(11203700015)).to.be.true;
expect(chance.luhn_check('10384030010')).to.be.true;
expect(chance.luhn_check(11401610016)).to.be.true;
expect(chance.luhn_check(09105080015)).to.be.true;
expect(chance.luhn_check(11203700011)).to.be.false;
expect(chance.luhn_check(09105080010)).to.be.false;
});
});
describe("Italian VAT number", function () {
it("returns a VAT code of 11 digits", function () {
_(1000).times(function () {
vat = chance.vat( { country: 'it' });
expect(vat).to.be.a("string");
expect(vat).to.have.length(11);
expect(vat[0]).to.be.within(0,1);
});
});
});
describe("Italian Codice Fiscale (SSN)", function () {
it("returns a random CF", function () {
_(1000).times(function () {
var cf = chance.cf();
expect(cf).to.be.a("string");
expect(cf).to.have.length(16);
expect(cf).to.match(/[A-Z]{6}\d{2}[A-Z]\d{2}[A-Z]\d{3}[A-Z]/);
});
});
it("checks the consistency of a specific CF", function () {
expect(chance.cf( { first: 'Aldo', last: 'Fabrizi', gender: 'Male', birthday: new Date(1905,10,1), city: 'h501' } )).to.equal("FBRLDA05S01H501A");
expect(chance.cf( { first: 'Sophia', last: 'Loren', gender: 'Female', birthday: new Date(1934,8,20), city: 'h501' } )).to.equal("LRNSPH34P60H501G");
expect(chance.cf( { first: 'Claudia', last: 'Cardinale', gender: 'Female', birthday: new Date(1938,3,15), city: 'z352' } )).to.equal("CRDCLD38D55Z352Q");
expect(chance.cf( { first: 'Sergio', last: 'Leone', gender: 'Male', birthday: new Date(1929,0,3), city: 'h501' } )).to.equal("LNESRG29A03H501W");
expect(chance.cf( { first: 'Claudio', last: 'Marchisio', gender: 'Male', birthday: new Date(1986,0,19), city: 'l219' } )).to.equal("MRCCLD86A19L219F");
expect(chance.cf( { first: 'Eu', last: 'Ho', gender: 'Male', birthday: new Date(2012,3,12), city: 'z210' } )).to.equal("HOXEUX12D12Z210Q");
});
});
});
});

Sorry, the diff of this file is not supported yet

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

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