diff options
| author | Adam Walker <[email protected]> | 2021-05-19 22:48:33 -0400 |
|---|---|---|
| committer | Adam Walker <[email protected]> | 2021-05-19 22:48:33 -0400 |
| commit | 45204bec008229f5b281ca5fdff0a25aece706a5 (patch) | |
| tree | 07d5c00e6f64c90db8bfe90692721fb72444ff1c /test | |
| parent | c1fe4d1d8f699956829e1a8efb0cedb9b9849099 (diff) | |
| download | faker-45204bec008229f5b281ca5fdff0a25aece706a5.tar.xz faker-45204bec008229f5b281ca5fdff0a25aece706a5.zip | |
Add remaining methods and libs from feature request.
Diffstat (limited to 'test')
| -rw-r--r-- | test/word.unit.js | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/test/word.unit.js b/test/word.unit.js index b7502708..071b6cfd 100644 --- a/test/word.unit.js +++ b/test/word.unit.js @@ -5,16 +5,33 @@ if (typeof module !== "undefined") { describe.only("word.js", function () { faker.seed(Math.random() * 100000000 + 1); - describe("noun()", function () { - it("returns random value from noun array", function () { - var noun = faker.word.noun(); - assert.ok(faker.definitions.word.noun.includes(noun)); - }); - }); - describe("verb()", function () { - it("returns random value from verb array", function () { - var verb = faker.word.verb(); - assert.ok(faker.definitions.word.verb.includes(verb)); + var methods = [ + "adjective", + "adverb", + "conjunction", + "interjection", + "noun", + "preposition", + "verb", + ]; + // Perform the same three tests for each method. + methods.forEach(function (method) { + describe(method + "()", function () { + it("returns random value from " + method + " array", function () { + var word = faker.word[method](); + assert.ok(faker.definitions.word[method].includes(word)); + }); + it("optional length parameter returns expected result", function () { + var wordLength = parseInt(Math.random() * 7 + 3); + var word = faker.word[method](wordLength); + assert.ok(faker.definitions.word[method].includes(word)); + assert.ok(word.length == wordLength); + }); + it("unable to find word of desired length returns stringified 'undefined'", function () { + var wordLength = 1000; + var word = faker.word[method](wordLength); + assert.ok(word === "undefined"); + }); }); }); }); |
