From f9b39f3cabcff2640237eb12afe8f24283e9ecfb Mon Sep 17 00:00:00 2001 From: "onyeka.mmakwe" Date: Thu, 2 May 2024 13:20:35 +0200 Subject: [PATCH] SDISCO-2399: update restuarant card --- .../molecules/f-restaurant-card/CHANGELOG.md | 10 ++++++++++ .../molecules/f-restaurant-card/package.json | 2 +- .../src/components/RestaurantCard.vue | 7 ++++++- .../RestaurantRating/RestaurantRating.vue | 9 +++++++-- .../RestaurantRating/_tests/RestaurantRating.test.js | 4 ++-- 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/packages/components/molecules/f-restaurant-card/CHANGELOG.md b/packages/components/molecules/f-restaurant-card/CHANGELOG.md index f14134c9e5..34b7a7438a 100644 --- a/packages/components/molecules/f-restaurant-card/CHANGELOG.md +++ b/packages/components/molecules/f-restaurant-card/CHANGELOG.md @@ -3,6 +3,16 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## v1.6.4 + +_May 2, 2024_ + +### Changed + +- Add maxDisplayRating prop to restuant card component +- Update logic for displaying restuarant rating +- Update tests + ## v1.6.3 _April 29, 2024_ diff --git a/packages/components/molecules/f-restaurant-card/package.json b/packages/components/molecules/f-restaurant-card/package.json index fe0b45028a..97fb18f7fc 100644 --- a/packages/components/molecules/f-restaurant-card/package.json +++ b/packages/components/molecules/f-restaurant-card/package.json @@ -1,7 +1,7 @@ { "name": "@justeat/f-restaurant-card", "description": "Fozzie Restaurant Card - Responsible for displaying restaurant data and linking to a restaurant", - "version": "1.6.3", + "version": "1.6.4", "main": "dist/f-restaurant-card.umd.min.js", "files": [ "dist", diff --git a/packages/components/molecules/f-restaurant-card/src/components/RestaurantCard.vue b/packages/components/molecules/f-restaurant-card/src/components/RestaurantCard.vue index f1a1c93efe..375f7ca191 100644 --- a/packages/components/molecules/f-restaurant-card/src/components/RestaurantCard.vue +++ b/packages/components/molecules/f-restaurant-card/src/components/RestaurantCard.vue @@ -68,7 +68,8 @@ v-if="rating" :tier="3"> + v-bind="rating" + :max-displayed-ratings="maxDisplayedRatings" /> @@ -322,6 +323,10 @@ export default { inlineTileData: { type: Boolean, default: false + }, + maxDisplayedRatings: { + type: Number, + default: 0 } }, computed: { diff --git a/packages/components/molecules/f-restaurant-card/src/components/subcomponents/RestaurantRating/RestaurantRating.vue b/packages/components/molecules/f-restaurant-card/src/components/subcomponents/RestaurantRating/RestaurantRating.vue index 6ff2d83ed6..06f023f876 100644 --- a/packages/components/molecules/f-restaurant-card/src/components/subcomponents/RestaurantRating/RestaurantRating.vue +++ b/packages/components/molecules/f-restaurant-card/src/components/subcomponents/RestaurantRating/RestaurantRating.vue @@ -122,7 +122,7 @@ export default { */ maxDisplayedRatings: { type: Number, - default: 200 + default: 0 }, /** * The max value of the rating @@ -168,7 +168,12 @@ export default { return Number.parseFloat(this.mean).toFixed(1); }, formattedCount () { - return this.count > this.maxDisplayedRatings ? `${this.maxDisplayedRatings}+` : this.count; + if (this.maxDisplayedRatings === 0) { + return this.count; + } else if (this.count > this.maxDisplayedRatings) { + return `${this.maxDisplayedRatings}+`; + } + return this.count; } } }; diff --git a/packages/components/molecules/f-restaurant-card/src/components/subcomponents/RestaurantRating/_tests/RestaurantRating.test.js b/packages/components/molecules/f-restaurant-card/src/components/subcomponents/RestaurantRating/_tests/RestaurantRating.test.js index c19ac60b9a..7efc1cd085 100644 --- a/packages/components/molecules/f-restaurant-card/src/components/subcomponents/RestaurantRating/_tests/RestaurantRating.test.js +++ b/packages/components/molecules/f-restaurant-card/src/components/subcomponents/RestaurantRating/_tests/RestaurantRating.test.js @@ -200,7 +200,7 @@ describe('RestaurantRating component', () => { expect(countMessage.text()).toStrictEqual('200+'); }); - it('displays threshold with + when count is higher than threshold with default threshold value', () => { + it('displays count when threshold has default threshold value', () => { // arrange const propsData = { mean: 5, @@ -215,7 +215,7 @@ describe('RestaurantRating component', () => { // assert expect(countMessage.exists()).toBe(true); - expect(countMessage.text()).toStrictEqual('200+'); + expect(countMessage.text()).toStrictEqual('250'); }); });