diff options
| author | Craig Morris <[email protected]> | 2015-12-01 11:49:13 +0000 |
|---|---|---|
| committer | Marak <[email protected]> | 2016-02-14 13:03:35 -0500 |
| commit | 0e739eb0926a67e230674fe83eb98062a8dd5a64 (patch) | |
| tree | 62f6e538c0c2b6d645e8e0a71b2858a6212e2ebe /test | |
| parent | 5f4843c6474c0cc60b0480b56ae0e6c0b53f6d4a (diff) | |
| download | faker-0e739eb0926a67e230674fe83eb98062a8dd5a64.tar.xz faker-0e739eb0926a67e230674fe83eb98062a8dd5a64.zip | |
Support parameters
Diffstat (limited to 'test')
| -rw-r--r-- | test/fake.unit.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/fake.unit.js b/test/fake.unit.js new file mode 100644 index 00000000..d0faa0da --- /dev/null +++ b/test/fake.unit.js @@ -0,0 +1,31 @@ +if (typeof module !== 'undefined') { + var assert = require('assert'); + var sinon = require('sinon'); + var faker = require('../index'); +} + +describe.only("fake.js", function () { + describe("fake()", function () { + it("replaces a token with a random value for a method with no parameters", function () { + var name = faker.fake('{{phone.phoneNumber}}'); + assert.ok(name.match(/\d/)); + }); + + it("replaces multiple tokens with random values for methods with no parameters", function () { + var name = faker.fake('{{helpers.randomize}}{{helpers.randomize}}{{helpers.randomize}}'); + assert.ok(name.match(/[abc]{3}/)); + }); + + it("replaces a token with a random value for a methods with a simple parameter", function () { + var arr = ["one", "two", "three"]; + var random = faker.fake('{{helpers.slugify("Will This Work")}}'); + assert.ok(random === "Will-This-Work"); + }); + + it("replaces a token with a random value for a method with an array parameter", function () { + var arr = ["one", "two", "three"]; + var random = faker.fake('{{helpers.randomize(["one", "two", "three"])}}'); + assert.ok(arr.indexOf(random) > -1); + }); + }); +}); |
