diff options
| author | Marak <[email protected]> | 2021-02-11 10:38:01 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-02-11 10:38:01 -0500 |
| commit | 08d43e82a2fa7d142695fa9102eb6ed1152e5791 (patch) | |
| tree | c1da445887d10ddcf6c6eb14b0c3973d8e9440b8 /test/random.unit.js | |
| parent | 65d2f9e5ad366a92de619d855ee278628b67de33 (diff) | |
| parent | 12f624a5473b5f4b37078ecb1bb931f2a801417f (diff) | |
| download | faker-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/random.unit.js')
| -rw-r--r-- | test/random.unit.js | 38 |
1 files changed, 30 insertions, 8 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; |
