From 6c15cde2c020b4dc154f1252d6afc8281c84c68f Mon Sep 17 00:00:00 2001 From: Matt Mayer Date: Sat, 12 Oct 2024 10:05:11 +0700 Subject: [PATCH 1/2] feat(commerce): more varied product descriptions fix #2871 samples: ``` Sleek Chips designed with Concrete for substantial performance Kuhn and Sons's most advanced Soap technology increases better capabilities New magenta Hat with ergonomic design for worthwhile comfort Ergonomic Car made with Granite for all-day somber support New Chicken model with 28 GB RAM, 969 GB storage, and winding features Stylish Table designed to make you stand out with dark looks The Enterprise-wide dedicated groupware Chips offers reliable performance and empty design Professional-grade Pizza perfect for same training and recreational use The Jessika Ball is the latest in a series of bleak products from Hickle, Langworth and Jaskolski Innovative Chips featuring authentic technology and Rubber construction Discover the young new Shoes with an exciting mix of Fresh ingredients The sleek and gigantic Pizza comes with purple LED lighting for smart functionality Introducing the Japan-inspired Mouse, blending better style with local craftsmanship Our fish-friendly Tuna ensures meager comfort for your pets Experience the plum brilliance of our Chair, perfect for shoddy environments Savor the fluffy essence in our Cheese, designed for mediocre culinary adventures Featuring Vanadium-enhanced technology, our Shoes offers unparalleled muted performance The tan Keyboard combines Gibraltar aesthetics with Argon-based durability Our delicious-inspired Computer brings a taste of luxury to your all lifestyle Discover the lion-like agility of our Keyboard, perfect for valuable users ``` --- .../en/commerce/product_description.ts | 32 ++++++++++++------- src/modules/commerce/index.ts | 4 +-- .../__snapshots__/commerce.spec.ts.snap | 6 ++-- test/modules/commerce.spec.ts | 7 ++-- 4 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/locales/en/commerce/product_description.ts b/src/locales/en/commerce/product_description.ts index ddaa271eaa5..d7a05361d82 100644 --- a/src/locales/en/commerce/product_description.ts +++ b/src/locales/en/commerce/product_description.ts @@ -1,14 +1,22 @@ export default [ - 'Andy shoes are designed to keeping in mind durability as well as trends, the most stylish range of shoes & sandals', - "Boston's most advanced compression wear technology increases muscle oxygenation, stabilizes active muscles", - 'Carbonite web goalkeeper gloves are ergonomically designed to give easy fit', - 'Ergonomic executive chair upholstered in bonded black leather and PVC padded seat and back for all-day comfort and support', - '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', - 'New range of formal shirts are designed keeping you in mind. With fits and styling that will make you stand apart', - 'The Apollotech B340 is an affordable wireless mouse with reliable connectivity, 12 months battery life and modern design', - 'The Football Is Good For Training And Recreational Purposes', - 'The Nagasaki Lander is the trademarked name of several series of Nagasaki sport bikes, that started with the 1984 ABC800J', - 'The automobile layout consists of a front-engine design, with transaxle-type transmissions mounted at the rear of the engine and four wheel drive', - 'The beautiful range of Apple Naturalé that has an exciting mix of natural ingredients. With the Goodness of 100% Natural Ingredients', - 'The slim & simple Maple Gaming Keyboard from Dev Byte comes with a sleek body and 7- Color RGB LED Back-lighting for smart functionality', + '{{commerce.productAdjective}} {{commerce.product}} designed with {{commerce.productMaterial}} for {{word.adjective}} performance', + "{{company.name}}'s most advanced {{commerce.product}} technology increases {{word.adjective}} capabilities", + 'New {{color.human}} {{commerce.product}} with ergonomic design for {{word.adjective}} comfort', + 'Ergonomic {{commerce.product}} made with {{commerce.productMaterial}} for all-day {{word.adjective}} support', + 'New {{commerce.product}} model with {{number.int({"min": 1, "max": 100})}} GB RAM, {{number.int({"min": 1, "max": 1000})}} GB storage, and {{word.adjective}} features', + 'Stylish {{commerce.product}} designed to make you stand out with {{word.adjective}} looks', + 'The {{company.catchPhrase}} {{commerce.product}} offers reliable performance and {{word.adjective}} design', + 'Professional-grade {{commerce.product}} perfect for {{word.adjective}} training and recreational use', + 'The {{person.firstName}} {{commerce.product}} is the latest in a series of {{word.adjective}} products from {{company.name}}', + 'Innovative {{commerce.product}} featuring {{word.adjective}} technology and {{commerce.productMaterial}} construction', + 'Discover the {{word.adjective}} new {{commerce.product}} with an exciting mix of {{commerce.productMaterial}} ingredients', + 'The sleek and {{word.adjective}} {{commerce.product}} comes with {{color.human}} LED lighting for smart functionality', + 'Introducing the {{location.country}}-inspired {{commerce.product}}, blending {{word.adjective}} style with local craftsmanship', + 'Our {{animal.type}}-friendly {{commerce.product}} ensures {{word.adjective}} comfort for your pets', + 'Experience the {{color.human}} brilliance of our {{commerce.product}}, perfect for {{word.adjective}} environments', + 'Savor the {{food.adjective}} essence in our {{commerce.product}}, designed for {{word.adjective}} culinary adventures', + 'Featuring {{science.chemical_element.name}}-enhanced technology, our {{commerce.product}} offers unparalleled {{word.adjective}} performance', + 'The {{color.human}} {{commerce.product}} combines {{location.country}} aesthetics with {{science.chemical_element.name}}-based durability', + 'Our {{food.adjective}}-inspired {{commerce.product}} brings a taste of luxury to your {{word.adjective}} lifestyle', + 'Discover the {{animal.type}}-like agility of our {{commerce.product}}, perfect for {{word.adjective}} users', ]; diff --git a/src/modules/commerce/index.ts b/src/modules/commerce/index.ts index 12ab94b8575..61dd9a9c2b9 100644 --- a/src/modules/commerce/index.ts +++ b/src/modules/commerce/index.ts @@ -254,12 +254,12 @@ export class CommerceModule extends ModuleBase { * Returns a product description. * * @example - * faker.commerce.productDescription() // 'Andy shoes are designed to keeping...' + * faker.commerce.productDescription() // 'Featuring Phosphorus-enhanced technology, our Fish offers unparalleled Modern performance' * * @since 5.0.0 */ productDescription(): string { - return this.faker.helpers.arrayElement( + return this.faker.helpers.fake( this.faker.definitions.commerce.product_description ); } diff --git a/test/modules/__snapshots__/commerce.spec.ts.snap b/test/modules/__snapshots__/commerce.spec.ts.snap index efad4c8ff0d..11dff82a2c8 100644 --- a/test/modules/__snapshots__/commerce.spec.ts.snap +++ b/test/modules/__snapshots__/commerce.spec.ts.snap @@ -30,7 +30,7 @@ exports[`commerce > 42 > product 1`] = `"Computer"`; exports[`commerce > 42 > productAdjective 1`] = `"Handcrafted"`; -exports[`commerce > 42 > productDescription 1`] = `"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"`; +exports[`commerce > 42 > productDescription 1`] = `"Professional-grade Towels perfect for pastel training and recreational use"`; exports[`commerce > 42 > productMaterial 1`] = `"Frozen"`; @@ -66,7 +66,7 @@ exports[`commerce > 1211 > product 1`] = `"Towels"`; exports[`commerce > 1211 > productAdjective 1`] = `"Tasty"`; -exports[`commerce > 1211 > productDescription 1`] = `"The slim & simple Maple Gaming Keyboard from Dev Byte comes with a sleek body and 7- Color RGB LED Back-lighting for smart functionality"`; +exports[`commerce > 1211 > productDescription 1`] = `"Our delicious-inspired Tuna brings a taste of luxury to your right lifestyle"`; exports[`commerce > 1211 > productMaterial 1`] = `"Wooden"`; @@ -102,7 +102,7 @@ exports[`commerce > 1337 > product 1`] = `"Chicken"`; exports[`commerce > 1337 > productAdjective 1`] = `"Generic"`; -exports[`commerce > 1337 > productDescription 1`] = `"Ergonomic executive chair upholstered in bonded black leather and PVC padded seat and back for all-day comfort and support"`; +exports[`commerce > 1337 > productDescription 1`] = `"Stylish Car designed to make you stand out with lawful looks"`; exports[`commerce > 1337 > productMaterial 1`] = `"Fresh"`; diff --git a/test/modules/commerce.spec.ts b/test/modules/commerce.spec.ts index e009e93057d..ceca3a1376b 100644 --- a/test/modules/commerce.spec.ts +++ b/test/modules/commerce.spec.ts @@ -187,11 +187,10 @@ describe('commerce', () => { }); describe(`productDescription()`, () => { - it('should return random value from product description array', () => { + it('should return a product description string', () => { const actual = faker.commerce.productDescription(); - expect(faker.definitions.commerce.product_description).toContain( - actual - ); + expect(actual).toBeTruthy(); + expect(actual).toBeTypeOf('string'); }); }); From 1887ed1316a1defdc5d24d842991670ba629e075 Mon Sep 17 00:00:00 2001 From: Matt Mayer Date: Sat, 12 Oct 2024 10:38:51 +0700 Subject: [PATCH 2/2] fix sort --- .../en/commerce/product_description.ts | 28 +++++++++---------- .../__snapshots__/commerce.spec.ts.snap | 6 ++-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/locales/en/commerce/product_description.ts b/src/locales/en/commerce/product_description.ts index d7a05361d82..725e32da9d8 100644 --- a/src/locales/en/commerce/product_description.ts +++ b/src/locales/en/commerce/product_description.ts @@ -1,22 +1,22 @@ export default [ - '{{commerce.productAdjective}} {{commerce.product}} designed with {{commerce.productMaterial}} for {{word.adjective}} performance', - "{{company.name}}'s most advanced {{commerce.product}} technology increases {{word.adjective}} capabilities", - 'New {{color.human}} {{commerce.product}} with ergonomic design for {{word.adjective}} comfort', + 'Discover the {{animal.type}}-like agility of our {{commerce.product}}, perfect for {{word.adjective}} users', + 'Discover the {{word.adjective}} new {{commerce.product}} with an exciting mix of {{commerce.productMaterial}} ingredients', 'Ergonomic {{commerce.product}} made with {{commerce.productMaterial}} for all-day {{word.adjective}} support', - 'New {{commerce.product}} model with {{number.int({"min": 1, "max": 100})}} GB RAM, {{number.int({"min": 1, "max": 1000})}} GB storage, and {{word.adjective}} features', - 'Stylish {{commerce.product}} designed to make you stand out with {{word.adjective}} looks', - 'The {{company.catchPhrase}} {{commerce.product}} offers reliable performance and {{word.adjective}} design', - 'Professional-grade {{commerce.product}} perfect for {{word.adjective}} training and recreational use', - 'The {{person.firstName}} {{commerce.product}} is the latest in a series of {{word.adjective}} products from {{company.name}}', + 'Experience the {{color.human}} brilliance of our {{commerce.product}}, perfect for {{word.adjective}} environments', + 'Featuring {{science.chemical_element.name}}-enhanced technology, our {{commerce.product}} offers unparalleled {{word.adjective}} performance', 'Innovative {{commerce.product}} featuring {{word.adjective}} technology and {{commerce.productMaterial}} construction', - 'Discover the {{word.adjective}} new {{commerce.product}} with an exciting mix of {{commerce.productMaterial}} ingredients', - 'The sleek and {{word.adjective}} {{commerce.product}} comes with {{color.human}} LED lighting for smart functionality', 'Introducing the {{location.country}}-inspired {{commerce.product}}, blending {{word.adjective}} style with local craftsmanship', + 'New {{color.human}} {{commerce.product}} with ergonomic design for {{word.adjective}} comfort', + 'New {{commerce.product}} model with {{number.int({"min": 1, "max": 100})}} GB RAM, {{number.int({"min": 1, "max": 1000})}} GB storage, and {{word.adjective}} features', 'Our {{animal.type}}-friendly {{commerce.product}} ensures {{word.adjective}} comfort for your pets', - 'Experience the {{color.human}} brilliance of our {{commerce.product}}, perfect for {{word.adjective}} environments', + 'Our {{food.adjective}}-inspired {{commerce.product}} brings a taste of luxury to your {{word.adjective}} lifestyle', + 'Professional-grade {{commerce.product}} perfect for {{word.adjective}} training and recreational use', 'Savor the {{food.adjective}} essence in our {{commerce.product}}, designed for {{word.adjective}} culinary adventures', - 'Featuring {{science.chemical_element.name}}-enhanced technology, our {{commerce.product}} offers unparalleled {{word.adjective}} performance', + 'Stylish {{commerce.product}} designed to make you stand out with {{word.adjective}} looks', + 'The sleek and {{word.adjective}} {{commerce.product}} comes with {{color.human}} LED lighting for smart functionality', 'The {{color.human}} {{commerce.product}} combines {{location.country}} aesthetics with {{science.chemical_element.name}}-based durability', - 'Our {{food.adjective}}-inspired {{commerce.product}} brings a taste of luxury to your {{word.adjective}} lifestyle', - 'Discover the {{animal.type}}-like agility of our {{commerce.product}}, perfect for {{word.adjective}} users', + 'The {{company.catchPhrase}} {{commerce.product}} offers reliable performance and {{word.adjective}} design', + 'The {{person.firstName}} {{commerce.product}} is the latest in a series of {{word.adjective}} products from {{company.name}}', + '{{commerce.productAdjective}} {{commerce.product}} designed with {{commerce.productMaterial}} for {{word.adjective}} performance', + "{{company.name}}'s most advanced {{commerce.product}} technology increases {{word.adjective}} capabilities", ]; diff --git a/test/modules/__snapshots__/commerce.spec.ts.snap b/test/modules/__snapshots__/commerce.spec.ts.snap index 11dff82a2c8..11d5503849f 100644 --- a/test/modules/__snapshots__/commerce.spec.ts.snap +++ b/test/modules/__snapshots__/commerce.spec.ts.snap @@ -30,7 +30,7 @@ exports[`commerce > 42 > product 1`] = `"Computer"`; exports[`commerce > 42 > productAdjective 1`] = `"Handcrafted"`; -exports[`commerce > 42 > productDescription 1`] = `"Professional-grade Towels perfect for pastel training and recreational use"`; +exports[`commerce > 42 > productDescription 1`] = `"New salmon Pants with ergonomic design for crushing comfort"`; exports[`commerce > 42 > productMaterial 1`] = `"Frozen"`; @@ -66,7 +66,7 @@ exports[`commerce > 1211 > product 1`] = `"Towels"`; exports[`commerce > 1211 > productAdjective 1`] = `"Tasty"`; -exports[`commerce > 1211 > productDescription 1`] = `"Our delicious-inspired Tuna brings a taste of luxury to your right lifestyle"`; +exports[`commerce > 1211 > productDescription 1`] = `"Small Cheese designed with Wooden for right performance"`; exports[`commerce > 1211 > productMaterial 1`] = `"Wooden"`; @@ -102,7 +102,7 @@ exports[`commerce > 1337 > product 1`] = `"Chicken"`; exports[`commerce > 1337 > productAdjective 1`] = `"Generic"`; -exports[`commerce > 1337 > productDescription 1`] = `"Stylish Car designed to make you stand out with lawful looks"`; +exports[`commerce > 1337 > productDescription 1`] = `"Innovative Car featuring lawful technology and Fresh construction"`; exports[`commerce > 1337 > productMaterial 1`] = `"Fresh"`;