diff options
| author | Marak <[email protected]> | 2020-06-10 11:49:35 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-06-10 11:49:35 -0500 |
| commit | ad095d1544b2aba54aa41ad2a9ab2b2d1addfabb (patch) | |
| tree | 646a51f93db9930e09196e56a1bb5e82e33b937a | |
| parent | a4e7842235e83d1272b8398c9a99f8126c3a510a (diff) | |
| parent | 34bf995ab27c504db60b14b0e3af3fd99635760a (diff) | |
| download | faker-ad095d1544b2aba54aa41ad2a9ab2b2d1addfabb.tar.xz faker-ad095d1544b2aba54aa41ad2a9ab2b2d1addfabb.zip | |
Merge pull request #823 from ashishra0/add-product-description
add random product description generator
| -rw-r--r-- | Readme.md | 1 | ||||
| -rw-r--r-- | lib/commerce.js | 9 | ||||
| -rw-r--r-- | lib/index.js | 2 | ||||
| -rw-r--r-- | lib/locales/en/commerce/index.js | 1 | ||||
| -rw-r--r-- | lib/locales/en/commerce/product_description.js | 14 | ||||
| -rw-r--r-- | test/commerce.unit.js | 12 |
6 files changed, 38 insertions, 1 deletions
@@ -90,6 +90,7 @@ This will interpolate the format string with the value of methods `name.lastName * productAdjective * productMaterial * product + * productDescription * company * suffixes * companyName diff --git a/lib/commerce.js b/lib/commerce.js index 79316256..6de8ffb9 100644 --- a/lib/commerce.js +++ b/lib/commerce.js @@ -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; }; diff --git a/lib/index.js b/lib/index.js index a4e8b26a..c9c00d9c 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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"], diff --git a/lib/locales/en/commerce/index.js b/lib/locales/en/commerce/index.js index c05b5272..89187f7c 100644 --- a/lib/locales/en/commerce/index.js +++ b/lib/locales/en/commerce/index.js @@ -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"); diff --git a/lib/locales/en/commerce/product_description.js b/lib/locales/en/commerce/product_description.js new file mode 100644 index 00000000..05ab517c --- /dev/null +++ b/lib/locales/en/commerce/product_description.js @@ -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" +];
\ No newline at end of file diff --git a/test/commerce.unit.js b/test/commerce.unit.js index a0336c47..04d4277e 100644 --- a/test/commerce.unit.js +++ b/test/commerce.unit.js @@ -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(); + }); + }); + }); |
