diff options
| -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'); |
