Comparing version 1.0.4 to 1.0.5
{ | ||
"name": "chance", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"main": "chance.js", | ||
@@ -5,0 +5,0 @@ "ignore": [ |
@@ -5,3 +5,3 @@ { | ||
"description": "Minimalist generator of random strings, numbers, etc.", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"keywords": ["chance", "random", "generator", "test"], | ||
@@ -8,0 +8,0 @@ "main": "chance.js", |
{ | ||
"name": "chance", | ||
"main": "./chance.js", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Chance - Utility library to generate anything random", | ||
@@ -6,0 +6,0 @@ "homepage": "http://chancejs.com", |
@@ -146,4 +146,4 @@ /// <reference path="../chance.js" /> | ||
it("states({country: 'uk') returns 90 UK Conties", function () { | ||
expect(chance.states({country: 'uk'})).to.have.length(90); | ||
it("states({country: 'uk') returns 129 UK Conties", function () { | ||
expect(chance.states({country: 'uk'})).to.have.length(129); | ||
}); | ||
@@ -150,0 +150,0 @@ }); |
@@ -147,7 +147,7 @@ /* jshint newcap:false */ | ||
it("is always positive", function () { | ||
it("is always positive or zero", function () { | ||
var positive_count = 0; | ||
_(1000).times(function () { | ||
natural = chance.natural(); | ||
if (natural > 0) { | ||
if (natural >= 0) { | ||
positive_count++; | ||
@@ -154,0 +154,0 @@ } |
@@ -11,3 +11,3 @@ /// <reference path="../chance.js" /> | ||
var fileExtension = { | ||
var fileExtensions = { | ||
"raster" : ["bmp", "gif", "gpl", "ico", "jpeg", "psd", "png", "psp", "raw", "tiff"], | ||
@@ -19,8 +19,8 @@ "vector" : ["3dv", "amf", "awg", "ai", "cgm", "cdr", "cmx", "dxf", "e2d", "egt", "eps", "fs", "odg", "svg", "xar"], | ||
var arrayExtentionCollection = ["bmp", "3dv", "3dmf", "doc"]; | ||
var arrayExtensionCollection = ["bmp", "3dv", "3dmf", "doc"]; | ||
var objectExtentionCollection = { | ||
"one" : ["extention_one_1", "extention_one_2", "extention_one_3"], | ||
"two" : ["extention_two_1", "extention_two_2", "extention_two_3" ], | ||
"three" : ["extention_three_1", "extention_three_2", "extention_three_3"] | ||
var objectExtensionCollection = { | ||
"one" : ["extension_one_1", "extension_one_2", "extension_one_3"], | ||
"two" : ["extension_two_1", "extension_two_2", "extension_two_3" ], | ||
"three" : ["extension_three_1", "extension_three_2", "extension_three_3"] | ||
}; | ||
@@ -64,10 +64,10 @@ | ||
var extentionTypeCollection = ['raster', 'vector', '3d', '']; | ||
var firstExtentionType = extentionTypeCollection[0]; | ||
var extensionTypeCollection = ['raster', 'vector', '3d', '']; | ||
var firstExtensionType = extensionTypeCollection[0]; | ||
file = chance.file({fileType : firstExtentionType}); | ||
file = chance.file({fileType : firstExtensionType}); | ||
expect(file).to.be.a('string'); | ||
var fileExtention = file.split('.')[1]; | ||
var fileExtension = file.split('.')[1]; | ||
expect(fileExtension[firstExtentionType]).to.contain(fileExtention); | ||
expect(fileExtensions[firstExtensionType]).to.contain(fileExtension); | ||
}); | ||
@@ -79,11 +79,11 @@ }); | ||
var specificExtention = 'doc'; | ||
var failTestExtention = 'xml'; | ||
var specificExtension = 'doc'; | ||
var failTestExtension = 'xml'; | ||
file = chance.file({extention : specificExtention}); | ||
var fileExtention = file.split('.')[1]; | ||
file = chance.file({extension : specificExtension}); | ||
var fileExtension = file.split('.')[1]; | ||
expect(fileExtention).to.be.a('string'); | ||
expect(fileExtention).to.equal(specificExtention); | ||
expect(fileExtention).to.not.equal(failTestExtention); | ||
expect(fileExtension).to.be.a('string'); | ||
expect(fileExtension).to.equal(specificExtension); | ||
expect(fileExtension).to.not.equal(failTestExtension); | ||
}); | ||
@@ -107,11 +107,11 @@ }); | ||
it("returns filename with random extention provided by external array collection", function() { | ||
it("returns filename with random extension provided by external array collection", function() { | ||
_(1000).times(function() { | ||
var arrayExtentionCollection = ["bmp", "3dv", "3dmf", "doc"]; | ||
file = chance.file({ extentions : arrayExtentionCollection}); | ||
var fileExtention = file.split('.')[1]; | ||
var arrayExtensionCollection = ["bmp", "3dv", "3dmf", "doc"]; | ||
file = chance.file({ extensions : arrayExtensionCollection}); | ||
var fileExtension = file.split('.')[1]; | ||
expect(arrayExtentionCollection).to.include(fileExtention); | ||
expect(arrayExtensionCollection).to.include(fileExtension); | ||
}); | ||
@@ -125,9 +125,9 @@ }); | ||
file = chance.file({ extentions : objectExtentionCollection}); | ||
var fileExtention = file.split('.')[1]; | ||
file = chance.file({ extensions : objectExtensionCollection}); | ||
var fileExtension = file.split('.')[1]; | ||
var extentionCount = 0; | ||
for(var index in objectExtentionCollection) { | ||
var extensionCount = 0; | ||
for(var index in objectExtensionCollection) { | ||
var collection = objectExtentionCollection[index]; | ||
var collection = objectExtensionCollection[index]; | ||
var length = collection.length; | ||
@@ -137,4 +137,4 @@ var i = 0; | ||
for(i; i < length; i++) { | ||
if(collection[i] === fileExtention) { | ||
extentionCount++; | ||
if(collection[i] === fileExtension) { | ||
extensionCount++; | ||
} | ||
@@ -144,8 +144,8 @@ } | ||
expect(fileExtention).to.be.a('string'); | ||
expect(extentionCount).to.be.equal(1); | ||
expect(fileExtension).to.be.a('string'); | ||
expect(extensionCount).to.be.equal(1); | ||
}); | ||
}); | ||
it("returns error if user provides wrong argument type to extentions property", function() { | ||
it("returns error if user provides wrong argument type to extensions property", function() { | ||
@@ -155,3 +155,3 @@ _(1000).times(function() { | ||
expect(function() { | ||
chance({ extentions : 10}); | ||
chance({ extensions : 10}); | ||
}).to.throw(Error); | ||
@@ -161,3 +161,3 @@ }); | ||
it("doesnot returns error if user provides correct array argument type to extentions property", function() { | ||
it("doesnot returns error if user provides correct array argument type to extensions property", function() { | ||
@@ -167,3 +167,3 @@ _(1000).times(function() { | ||
expect(function() { | ||
chance.file({ extentions : arrayExtentionCollection}); | ||
chance.file({ extensions : arrayExtensionCollection}); | ||
}).to.not.throw(Error); | ||
@@ -173,3 +173,3 @@ }); | ||
it("doesnot returns error if user provides correct object argument type to extentions property", function() { | ||
it("doesnot returns error if user provides correct object argument type to extensions property", function() { | ||
@@ -179,3 +179,3 @@ _(1000).times(function() { | ||
expect(function() { | ||
chance.file({ extentions : objectExtentionCollection}); | ||
chance.file({ extensions : objectExtensionCollection}); | ||
}).to.not.throw(Error); | ||
@@ -182,0 +182,0 @@ }); |
@@ -217,1 +217,13 @@ /// <reference path="../chance.js" /> | ||
}); | ||
describe("IBAN", function () { | ||
var iban, chance = new Chance(); | ||
it("returns an iban", function () { | ||
_(1000).times(function () { | ||
iban = chance.iban(); | ||
expect(iban).to.be.a('string'); | ||
expect(iban).to.match(/^[A-Z]{2}[0-9]{2}[A-Z0-9]{4}[0-9]{1,26}$/); | ||
}); | ||
}); | ||
}); |
@@ -179,2 +179,8 @@ /// <reference path="../chance.js" /> | ||
it("throws an Error if weights contain NaN", function() { | ||
expect(function () { | ||
chance.weighted(['a', 'b', 'c', 'd'], [1, NaN, 1, 1]); | ||
}).to.throw(RangeError, /all weights must be numbers/); | ||
}); | ||
it("returns with results properly weighted", function() { | ||
@@ -181,0 +187,0 @@ // Use Math.random as the random function rather than our Mersenne twister just to |
@@ -24,3 +24,3 @@ /// <reference path="../chance.js" /> | ||
expect(word).to.be.a('string'); | ||
expect(syllable).to.have.length.within(2, 9); | ||
expect(word).to.have.length.within(2, 9); | ||
}); | ||
@@ -27,0 +27,0 @@ }); |
@@ -346,7 +346,7 @@ /// <reference path="../chance.js" /> | ||
_(1000).times(function() { | ||
var color = chance.color({format : 'name'}); | ||
expect(color).to.be.a('string'); | ||
}); | ||
}); | ||
}); | ||
@@ -466,2 +466,11 @@ it("({casing: upper}) returns upper cased color", function () { | ||
describe('port()', function () { | ||
it('should create a number in the valid port range (0 - 65535)', function () { | ||
var port = chance.port(); | ||
expect(port).to.be.a('number'); | ||
expect(port).to.be.at.least(0); | ||
expect(port).to.be.at.most(65535); | ||
}); | ||
}); | ||
}); |
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
685284
8439