Skip to content

Commit

Permalink
Merge branch 'refs/heads/main' into next
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
#	android/app/build.gradle
#	ios/MobyDick/Info.plist
#	ios/MobyDickTests/Info.plist
#	package.json
#	packages/KeyboardAware/package.json
#	packages/calendar/package.json
#	packages/chart/package.json
#	packages/core/package.json
#	packages/dragAndDrop/package.json
#	packages/markdown/package.json
#	packages/utils/package.json
  • Loading branch information
Bibazavr committed Sep 5, 2024
2 parents 93a46dd + 7b10f5a commit aedd09a
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 1,159 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [7.34.1](https://github.com/lad-tech/mobydick/compare/v7.34.0...v7.34.1) (2024-09-05)


### Bug Fixes

* rating logic ([9699984](https://github.com/lad-tech/mobydick/commit/969998427bdbec423707a1ed1927c35e074aafa5))

# [7.35.0-next.3](https://github.com/lad-tech/mobydick/compare/v7.35.0-next.2...v7.35.0-next.3) (2024-09-02)


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,4 @@
"engines": {
"node": ">=18"
}
}
}
2 changes: 1 addition & 1 deletion packages/KeyboardAware/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@
"react-native": ">=0.66.4",
"react": ">=17.0.2"
}
}
}
2 changes: 1 addition & 1 deletion packages/calendar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@
"react-native-calendars": "^1.1292.0",
"@lad-tech/mobydick-core": "7.35.0-next.3"
}
}
}
2 changes: 1 addition & 1 deletion packages/chart/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@
"react-native-reanimated": ">=3.6.1",
"react-native-gesture-handler": ">=2.14.1"
}
}
}
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@
"dependencies": {
"@tabler/icons-react-native": "^3.7.0"
}
}
}
15 changes: 6 additions & 9 deletions packages/core/src/other/components/Rating/Rating.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,21 @@ const Rating: FC<TRating> = ({
const [styles] = useStyles(stylesCreate);
const ratingCount = Array(count).fill(0);

const handleRating = (startId: number) => {
if (!setCurrentRate) {
const handleRating = (starIndex: number) => {
const newRating = starIndex + 1;
if (currentRate === newRating) {
setCurrentRate(newRating - 1);
return;
}
if (currentRate === startId) {
setCurrentRate(currentRate + 1);
return;
}
setCurrentRate(startId);
setCurrentRate(newRating);
};

const stars = ratingCount.map((_, index) => (
<Star
key={'rating' + index}
filled={index <= currentRate - 1}
starId={index}
starIndex={index}
setRating={handleRating}
currentSelected={currentRate}
iconStyle={iconStyle}
iconSize={iconSize}
fillColor={fillColor}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,9 @@ describe('Rating', () => {
);
expect(toJSON()).toMatchSnapshot();
});
test('render rating 4', () => {
const onPress = jest.fn();
const {toJSON} = render(
<Rating count={4} setCurrentRate={onPress} currentRate={4} />,
);
expect(toJSON()).toMatchSnapshot();
});
test('render rating 5', () => {
const onPress = jest.fn();
const {toJSON} = render(
<Rating count={5} setCurrentRate={onPress} currentRate={5} />,
);
expect(toJSON()).toMatchSnapshot();
});
test('change rating', () => {
const onPress = jest.fn();
const {toJSON, getByLabelText} = render(
const {getByLabelText} = render(
<Rating count={5} setCurrentRate={onPress} currentRate={2} />,
);
const setRatingButton = getByLabelText(`${LABELS.ratingStarButton}4`);
Expand All @@ -57,17 +43,11 @@ describe('Rating', () => {
fireEvent.press(setRatingButton);
});

expect(setRatingButton.props.accessibilityState).toHaveProperty(
'disabled',
undefined,
);
expect(onPress).toHaveBeenCalledWith(4);

expect(toJSON()).toMatchSnapshot();
});
test('change rating is disabled', () => {
const onPress = jest.fn();
const {toJSON, getByLabelText} = render(
const {getByLabelText} = render(
<Rating
count={5}
setCurrentRate={onPress}
Expand All @@ -81,11 +61,6 @@ describe('Rating', () => {
fireEvent.press(setRatingButton);
});

expect(setRatingButton.props.accessibilityState).toHaveProperty(
'disabled',
true,
);

expect(toJSON()).toMatchSnapshot();
expect(onPress).toHaveBeenCalledTimes(0);
});
});
Loading

0 comments on commit aedd09a

Please sign in to comment.