Skip to content

Commit

Permalink
Merge pull request #823 from ashishra0/add-product-description
Browse files Browse the repository at this point in the history
add random product description generator
  • Loading branch information
Marak authored Jun 10, 2020
2 parents a4e7842 + 34bf995 commit ad095d1
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ This will interpolate the format string with the value of methods `name.lastName
* productAdjective
* productMaterial
* product
* productDescription
* company
* suffixes
* companyName
Expand Down
9 changes: 9 additions & 0 deletions lib/commerce.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,15 @@ var Commerce = function (faker) {
return faker.random.arrayElement(faker.definitions.commerce.product_name.product);
};

/**
* productDescription
*
* @method faker.commerce.productDescription
*/
self.productDescription = function() {
return faker.random.arrayElement(faker.definitions.commerce.product_description);
};

return self;
};

Expand Down
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function Faker (opts) {
"phone_number": ["formats"],
"finance": ["account_type", "transaction_type", "currency", "iban", "credit_card"],
"internet": ["avatar_uri", "domain_suffix", "free_email", "example_email", "password"],
"commerce": ["color", "department", "product_name", "price", "categories"],
"commerce": ["color", "department", "product_name", "price", "categories", "product_description"],
"database": ["collation", "column", "engine", "type"],
"system": ["mimeTypes", "directoryPaths"],
"date": ["month", "weekday"],
Expand Down
1 change: 1 addition & 0 deletions lib/locales/en/commerce/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ module['exports'] = commerce;
commerce.color = require("./color");
commerce.department = require("./department");
commerce.product_name = require("./product_name");
commerce.product_description = require("./product_description");
14 changes: 14 additions & 0 deletions lib/locales/en/commerce/product_description.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module["exports"] = [
"Ergonomic executive chair upholstered in bonded black leather and PVC padded seat and back for all-day comfort and support",
"The automobile layout consists of a front-engine design, with transaxle-type transmissions mounted at the rear of the engine and four wheel drive",
"New ABC 13 9370, 13.3, 5th Gen CoreA5-8250U, 8GB RAM, 256GB SSD, power UHD Graphics, OS 10 Home, OS Office A & J 2016",
"The slim & simple Maple Gaming Keyboard from Dev Byte comes with a sleek body and 7- Color RGB LED Back-lighting for smart functionality",
"The Apollotech B340 is an affordable wireless mouse with reliable connectivity, 12 months battery life and modern design",
"The Nagasaki Lander is the trademarked name of several series of Nagasaki sport bikes, that started with the 1984 ABC800J",
"The Football Is Good For Training And Recreational Purposes",
"Carbonite web goalkeeper gloves are ergonomically designed to give easy fit",
"Boston's most advanced compression wear technology increases muscle oxygenation, stabilizes active muscles",
"New range of formal shirts are designed keeping you in mind. With fits and styling that will make you stand apart",
"The beautiful range of Apple Naturalé that has an exciting mix of natural ingredients. With the Goodness of 100% Natural Ingredients",
"Andy shoes are designed to keeping in mind durability as well as trends, the most stylish range of shoes & sandals"
];
12 changes: 12 additions & 0 deletions test/commerce.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,16 @@ describe("commerce.js", function() {

});

describe("productDescription()", function() {
it("returns a random product description", function() {
sinon.spy(faker.commerce, 'productDescription');
var description = faker.commerce.productDescription();

assert.ok(typeof description === 'string');
assert.ok(faker.commerce.productDescription.calledOnce);

faker.commerce.productDescription.restore();
});
});

});

0 comments on commit ad095d1

Please sign in to comment.