diff options
| author | Iaroslav Popov <[email protected]> | 2017-08-10 15:18:05 +0200 |
|---|---|---|
| committer | Iaroslav Popov <[email protected]> | 2017-08-10 15:18:05 +0200 |
| commit | 496c81d2422ab5fd20dcb52dfc9dd22bdb773613 (patch) | |
| tree | ee2ad81231bbd6ea2f730ee02113ebf04e41b7d2 | |
| parent | 6cdb93efcbcaf222ac061cee5532374f72ea073e (diff) | |
| download | faker-496c81d2422ab5fd20dcb52dfc9dd22bdb773613.tar.xz faker-496c81d2422ab5fd20dcb52dfc9dd22bdb773613.zip | |
add alphanumeric symbol * to helpers.replaceSymbols
| -rw-r--r-- | lib/helpers.js | 2 | ||||
| -rw-r--r-- | test/helpers.unit.js | 9 |
2 files changed, 11 insertions, 0 deletions
diff --git a/lib/helpers.js b/lib/helpers.js index 635c4ecc..19a29665 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -69,6 +69,8 @@ var Helpers = function (faker) { str += faker.random.number(9); } else if (string.charAt(i) == "?") { str += faker.random.arrayElement(alpha); + } else if (string.charAt(i) == "*") { + str += faker.random.boolean() ? faker.random.arrayElement(alpha) : faker.random.number(9); } else { str += string.charAt(i); } diff --git a/test/helpers.unit.js b/test/helpers.unit.js index 707575ff..0fcc5876 100644 --- a/test/helpers.unit.js +++ b/test/helpers.unit.js @@ -21,6 +21,15 @@ describe("helpers.js", function () { }); }); + describe("replaceSymbols()", function () { + context("when '*' passed", function () { + it("replaces it with alphanumeric", function(){ + var num = faker.helpers.replaceSymbols('*AB'); + assert.ok(num.match(/\wAB/)); + }); + }); + }); + describe("shuffle()", function () { it("the output is the same length as the input", function () { sinon.spy(faker.random, 'number'); |
