Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: rating button #2820

Merged
merged 9 commits into from
Jun 15, 2023
40 changes: 15 additions & 25 deletions packages/tests/components/SfRatingButton/SfRatingButton.cy.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,29 @@
/// <reference path="../../../../node_modules/@percy/cypress/types/index.d.ts" />
import React from 'react';
import { SfRatingButtonSize, noop } from '@storefront-ui/shared';
import { SfRatingButtonSize } from '@storefront-ui/shared';
import { mount, useComponent } from '../../utils/mount';

const { vue: SfRatingButtonVue, react: SfRatingButtonReact } = useComponent('SfRatingButton');
import SfRatingButtonBaseObject from './SfRatingButton.PageObject';
import { isReact } from '../../utils/utils';

interface Props {
value?: number;
onChange?: (value: number) => void;
max?: number;
name?: string;
disabled?: boolean;
label?: string;
labelClassName?: string;
size?: `${SfRatingButtonSize}`;
getLabelText?: (value: number) => string;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

describe('SfRatingButton', () => {
const page = () => new SfRatingButtonBaseObject('ratingbutton');

const initializeComponent = (
props: {
value?: number;
onChange?: (value: number) => void;
max?: number;
name?: string;
disabled?: boolean;
label?: string;
size?: SfRatingButtonSize;
getLabelText?: (value: number) => string;
children?: () => JSX.Element;
} = {},
) => {
const {
value = 0,
onChange = noop,
max = 5,
name = 'sf-rating-button',
disabled = false,
label = 'Rating',
size = SfRatingButtonSize.base,
getLabelText = (value) => `${value} star`,
children,
} = props;
const initializeComponent = (props: Props = {}) => {
const { value, onChange, max, name, disabled, label, size, getLabelText, children } = props;
return mount({
vue: {
component: SfRatingButtonVue,
Expand Down