diff options
Diffstat (limited to 'test')
| -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 () { |
