diff options
| author | Jakub Mandula <[email protected]> | 2017-02-26 13:51:40 +0000 |
|---|---|---|
| committer | Jakub Mandula <[email protected]> | 2017-02-26 13:51:40 +0000 |
| commit | 232a2a58d70935c57d311b5ba237347f703c2131 (patch) | |
| tree | 69f695e62e17386988c47f8522bf5e14db193839 /test/lorem.unit.js | |
| parent | d6c20353360ef1eefb56128eeb50ece4f5845372 (diff) | |
| parent | f379057be0112d6732b056d93d1380be18e1087a (diff) | |
| download | faker-232a2a58d70935c57d311b5ba237347f703c2131.tar.xz faker-232a2a58d70935c57d311b5ba237347f703c2131.zip | |
Merge branch 'Mark/origin' into creditCard
Diffstat (limited to 'test/lorem.unit.js')
| -rw-r--r-- | test/lorem.unit.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/lorem.unit.js b/test/lorem.unit.js index fbf09497..300786b8 100644 --- a/test/lorem.unit.js +++ b/test/lorem.unit.js @@ -34,6 +34,36 @@ describe("lorem.js", function () { }); }); + describe("slug()", function () { + beforeEach(function () { + sinon.spy(faker.helpers, 'shuffle'); + }); + + afterEach(function () { + faker.helpers.shuffle.restore(); + }); + + var validateSlug = function (wordCount, str) { + assert.equal(1, str.match(/^[a-z][a-z-]*[a-z]$/).length); + assert.equal(wordCount - 1, str.match(/-/g).length); + }; + + context("when no 'wordCount' param passed in", function () { + it("returns a slug with three words", function () { + var str = faker.lorem.slug(); + validateSlug(3, str); + }); + }); + + context("when 'wordCount' param passed in", function () { + it("returns a slug with requested number of words", function () { + var str = faker.lorem.slug(7); + validateSlug(7, str); + }); + }); + + }); + /* describe("sentence()", function () { context("when no 'wordCount' or 'range' param passed in", function () { |
