aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMarak <[email protected]>2021-05-25 01:35:51 -0400
committerMarak <[email protected]>2021-05-25 01:35:51 -0400
commitf765f710b4a8715c66abc1404e5077a50722d318 (patch)
treedb93b23217fac0be50ab3678816d5912e8ce839d /test
parentb8d9bc9b904cb6a57db7f3c981f411a984e899cc (diff)
parentcb1cb46b6f4f4485816f78674ebcf0a6596bc67e (diff)
downloadfaker-f765f710b4a8715c66abc1404e5077a50722d318.tar.xz
faker-f765f710b4a8715c66abc1404e5077a50722d318.zip
Merge branch 'feature/word-types' of https://github.com/ad-walker/faker.js
Diffstat (limited to 'test')
-rw-r--r--test/word.unit.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/word.unit.js b/test/word.unit.js
new file mode 100644
index 00000000..692177ef
--- /dev/null
+++ b/test/word.unit.js
@@ -0,0 +1,36 @@
+if (typeof module !== "undefined") {
+ var assert = require("assert");
+ var faker = require("../index");
+}
+
+describe.only("word.js", function () {
+ 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 = 5;
+ var word = faker.word[method](wordLength);
+ assert.ok(faker.definitions.word[method].includes(word));
+ assert.ok(word.length == wordLength);
+ });
+ it("unresolvable optional length returns random " + method, function () {
+ var wordLength = 1000;
+ var word = faker.word[method](wordLength);
+ assert.ok(faker.definitions.word[method].includes(word));
+ });
+ });
+ });
+});