aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrii Kostenko <[email protected]>2021-06-05 19:39:06 +0300
committerAndrii Kostenko <[email protected]>2021-06-05 19:39:06 +0300
commit3aac69e8ab0d0337580de688a8e0134a20fdcc08 (patch)
tree6c646d299406e202176b25cd590f3de43d3a2bba
parent9c917bae5adf7046fc08b2ecac7702711557e4b9 (diff)
downloadfaker-3aac69e8ab0d0337580de688a8e0134a20fdcc08.tar.xz
faker-3aac69e8ab0d0337580de688a8e0134a20fdcc08.zip
change domainWord generation algorithm to <adjective>-<noun>
-rw-r--r--lib/internet.js2
-rw-r--r--test/internet.unit.js18
2 files changed, 12 insertions, 8 deletions
diff --git a/lib/internet.js b/lib/internet.js
index 91eedc1d..7ade42d8 100644
--- a/lib/internet.js
+++ b/lib/internet.js
@@ -197,7 +197,7 @@ var Internet = function (faker) {
* @method faker.internet.domainWord
*/
self.domainWord = function () {
- return faker.name.firstName().replace(/([\\~#&*{}/:<>?|\"'])/ig, '').toLowerCase();
+ return (faker.word.adjective() + '-' + faker.word.noun()).replace(/([\\~#&*{}/:<>?|\"'])/ig, '').toLowerCase();
};
self.domainWord.schema = {
diff --git a/test/internet.unit.js b/test/internet.unit.js
index f615656c..7f25f5bd 100644
--- a/test/internet.unit.js
+++ b/test/internet.unit.js
@@ -88,24 +88,28 @@ describe("internet.js", function () {
});
describe("domainWord()", function () {
- it("returns a lower-case firstName", function () {
- sinon.stub(faker.name, 'firstName').returns('FOO');
+ it("returns a lower-case adjective + noun", function () {
+ sinon.stub(faker.word, 'adjective').returns('RANDOM');
+ sinon.stub(faker.word, 'noun').returns('WORD');
var domain_word = faker.internet.domainWord();
assert.ok(domain_word);
- assert.strictEqual(domain_word, 'foo');
+ assert.strictEqual(domain_word, 'random-word');
- faker.name.firstName.restore();
+ faker.word.adjective.restore();
+ faker.word.noun.restore();
});
describe("when the firstName used contains a apostrophe", function () {
- sinon.stub(faker.name, 'firstName').returns('d\'angelo');
+ sinon.stub(faker.word, 'adjective').returns('an\'other');
+ sinon.stub(faker.word, 'noun').returns('no\'un');
var domain_word = faker.internet.domainWord();
it("should remove the apostrophe", function () {
- assert.strictEqual(domain_word, 'dangelo');
+ assert.strictEqual(domain_word, 'another-noun');
});
- faker.name.firstName.restore();
+ faker.word.adjective.restore();
+ faker.word.noun.restore();
});
});