aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMarak <[email protected]>2021-02-11 10:38:01 -0500
committerGitHub <[email protected]>2021-02-11 10:38:01 -0500
commit08d43e82a2fa7d142695fa9102eb6ed1152e5791 (patch)
treec1da445887d10ddcf6c6eb14b0c3973d8e9440b8 /test
parent65d2f9e5ad366a92de619d855ee278628b67de33 (diff)
parent12f624a5473b5f4b37078ecb1bb931f2a801417f (diff)
downloadfaker-08d43e82a2fa7d142695fa9102eb6ed1152e5791.tar.xz
faker-08d43e82a2fa7d142695fa9102eb6ed1152e5791.zip
Merge pull request #1063 from DanielLipowicz/fix/incorrectVinNumber
Fix issue 1062; Add new alpha and alphanumeric functionality
Diffstat (limited to 'test')
-rw-r--r--test/random.unit.js38
-rw-r--r--test/vehicle.unit.js2
2 files changed, 31 insertions, 9 deletions
diff --git a/test/random.unit.js b/test/random.unit.js
index ce2c6925..e068c905 100644
--- a/test/random.unit.js
+++ b/test/random.unit.js
@@ -266,32 +266,54 @@ describe("random.js", function () {
it('should return single letter when no count provided', function() {
assert.ok(alpha().length === 1);
- })
+ });
it('should return lowercase letter when no upcase option provided', function() {
assert.ok(alpha().match(/[a-z]/));
- })
+ });
it('should return uppercase when upcase option is true', function() {
assert.ok(alpha({ upcase: true }).match(/[A-Z]/));
- })
+ });
it('should generate many random letters', function() {
assert.ok(alpha(5).length === 5);
- })
- })
+ });
+
+ it('should be able to ban some characters', function() {
+ var alphaText = alpha(5,{bannedChars:['a', 'p']});
+ assert.ok(alphaText.length === 5);
+ assert.ok(alphaText.match(/[b-oq-z]/));
+ });
+ it('should be able handle mistake in banned characters array', function() {
+ var alphaText = alpha(5,{bannedChars:['a', 'a', 'p']});
+ assert.ok(alphaText.length === 5);
+ assert.ok(alphaText.match(/[b-oq-z]/));
+ });
+ });
describe('alphaNumeric', function() {
var alphaNumeric = faker.random.alphaNumeric;
it('should generate single character when no additional argument was provided', function() {
assert.ok(alphaNumeric().length === 1);
- })
+ });
it('should generate many random characters', function() {
assert.ok(alphaNumeric(5).length === 5);
- })
- })
+ });
+
+ it('should be able to ban some characters', function() {
+ var alphaText = alphaNumeric(5,{bannedChars:['a','p']});
+ assert.ok(alphaText.length === 5);
+ assert.ok(alphaText.match(/[b-oq-z]/));
+ });
+ it('should be able handle mistake in banned characters array', function() {
+ var alphaText = alphaNumeric(5,{bannedChars:['a','p','a']});
+ assert.ok(alphaText.length === 5);
+ assert.ok(alphaText.match(/[b-oq-z]/));
+ });
+ });
describe('hexaDecimal', function() {
var hexaDecimal = faker.random.hexaDecimal;
diff --git a/test/vehicle.unit.js b/test/vehicle.unit.js
index 5500d5e6..f03a7886 100644
--- a/test/vehicle.unit.js
+++ b/test/vehicle.unit.js
@@ -48,7 +48,7 @@ describe("vehicle.js", function () {
describe("vin()", function () {
it("returns valid vin number", function () {
var vin = faker.vehicle.vin();
- assert.ok(vin.match(/^[A-Z0-9]{10}[A-Z]{1}[A-Z0-9]{1}\d{5}$/));
+ assert.ok(vin.match(/^([A-HJ-NPR-Z0-9]{10}[A-HJ-NPR-Z0-9]{1}[A-HJ-NPR-Z0-9]{1}\d{5})$/));
});
});