forked from zuriby/Faker.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathword.unit.js
36 lines (35 loc) · 1.11 KB
/
word.unit.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
if (typeof module !== "undefined") {
var assert = require("assert");
var faker = require("../index");
}
describe("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));
});
});
});
});