Skip to content

Commit

Permalink
[email protected]: rating fixed point value (#2460)
Browse files Browse the repository at this point in the history
* Update: rating fixed point value

* Update: fixed tests

* Update: update review number

* Update: improve tests
  • Loading branch information
mmakwe-onyeka authored Mar 26, 2024
1 parent c905adf commit d6c2f5c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
8 changes: 8 additions & 0 deletions packages/components/molecules/f-restaurant-card/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
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.1

_March 25, 2024_

### Changed
- Update fixed point value of restaurant rating from 2 to 1
- Update max number of reviews

## v1.6.0

_March 13, 2024_
Expand Down
Original file line number Diff line number Diff line change
@@ -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.0",
"version": "1.6.1",
"main": "dist/f-restaurant-card.umd.min.js",
"files": [
"dist",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@
<data
data-test-id="rating"
:class="[$style['c-restaurantCard-rating-count']]"
:value="count">
{{ count }}
:value="formattedCount">
{{ formattedCount }}
</data>
&#41;
</span>
Expand Down Expand Up @@ -158,7 +158,10 @@ export default {
return !this.mean;
},
meanFormatted () {
return Number.parseFloat(this.mean).toFixed(2);
return Number.parseFloat(this.mean).toFixed(1);
},
formattedCount () {
return this.count > 200 ? '200+' : this.count;
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ describe('RestaurantRating component', () => {
});

it.each([
[1, '1.00'],
[2.5, '2.50'],
[4.33, '4.33'],
[2.337, '2.34'],
[4.5678902, '4.57'],
[4.5538902, '4.55']
])('fixes the rating mean value to a fixed point of 2 decimal places', (ratingsValue, expectedRenderedValue) => {
[1, '1.0'],
[2.5, '2.5'],
[4.33, '4.3'],
[2.337, '2.3'],
[4.5678902, '4.6'],
[4.5538902, '4.6']
])('fixes the rating mean value to a fixed point of 1 decimal place', (ratingsValue, expectedRenderedValue) => {
// arrange
const propsData = {
mean: ratingsValue,
Expand Down Expand Up @@ -118,7 +118,7 @@ describe('RestaurantRating component', () => {
expect(filledStarElement.exists()).toBe(true);
expect(ownRatingMessageElement.exists()).toBe(true);

expect(ratingsMeanElement.text()).toStrictEqual('5.00');
expect(ratingsMeanElement.text()).toStrictEqual('5.0');
expect(ownRatingMessageElement.text()).toStrictEqual(isOwnRatingMessage);
});

Expand Down Expand Up @@ -188,8 +188,8 @@ describe('RestaurantRating component', () => {
expect(filledStarElement.exists()).toBe(true);
expect(countMessage.exists()).toBe(true);

expect(ratingsMeanElement.text()).toStrictEqual('5.00');
expect(countMessage.text()).toStrictEqual('250');
expect(ratingsMeanElement.text()).toStrictEqual('5.0');
expect(countMessage.text()).toStrictEqual('200+');
});

it('shows an empty star and a no ratings message if `mean` is missing', () => {
Expand Down

0 comments on commit d6c2f5c

Please sign in to comment.