diff --git a/packages/components/src/Button/Button.tsx b/packages/components/src/Button/Button.tsx index 950d5a0a60..5c15f65ccf 100644 --- a/packages/components/src/Button/Button.tsx +++ b/packages/components/src/Button/Button.tsx @@ -11,6 +11,7 @@ export interface IBtnProps extends React.ButtonHTMLAttributes { small?: boolean large?: boolean showIconOnly?: boolean + iconColor?: string } type ToArray = [Type] extends [any] ? Type[] : never @@ -112,7 +113,7 @@ export const Button = (props: BtnProps) => { pointerEvents: 'none', }} > - + )} ` min-width: ${(props) => (props.size ? `${props.size}px` : '32px')}; min-height: ${(props) => (props.size ? `${props.size}px` : '32px')}; position: relative; - color: ${(props) => (props.color ? `${props.color}` : 'inherit')}; - ${verticalAlign} - ${space} - - ${(props) => + color: ${(props) => props.color || 'inherit'}; + ${verticalAlign} ${space} + ${(props) => props.onClick && ` cursor: pointer; - `} + `}; ` const sizeMap = { diff --git a/packages/components/src/UserStatistics/__snapshots__/UserStatistics.test.tsx.snap b/packages/components/src/UserStatistics/__snapshots__/UserStatistics.test.tsx.snap index 87c4ecb63b..5c2121c4bf 100644 --- a/packages/components/src/UserStatistics/__snapshots__/UserStatistics.test.tsx.snap +++ b/packages/components/src/UserStatistics/__snapshots__/UserStatistics.test.tsx.snap @@ -12,7 +12,7 @@ exports[`UserStatistics > renders correctly 1`] = ` class="css-i1ihic-Box" >
renders correctly 1`] = ` class="css-i1ihic-Box" >
renders correctly 1`] = ` class="css-i1ihic-Box" >
({ @@ -28,7 +31,9 @@ jest.mock('src/index', () => ({ jest.mock('src/stores/Research/research.store') -import ResearchArticle from './ResearchArticle' +const activeUser = FactoryUser({ + userRoles: ['beta-tester'], +}) describe('Research Article', () => { const mockResearchStore = { @@ -75,6 +80,49 @@ describe('Research Article', () => { expect(wrapper.getAllByText('another-example-username')).toHaveLength(1) }) + it('displays "Follow" button text and color if not subscribed', async () => { + // Arrange + ;(useResearchStore as jest.Mock).mockReturnValue({ + ...mockResearchStore, + }) + + // Act + const wrapper = getWrapper() + const followingButton = wrapper.getByTestId('following-button') + + // Assert + expect(wrapper.getAllByText('Follow').length).toBeGreaterThan(0) + expect(followingButton).toBeInTheDocument() + expect(followingButton).toHaveAttribute( + 'iconcolor', + Theme.colors.notSubscribed, + ) + }) + + it('displays "Following" button text and color if user is subscribed', async () => { + // Arrange + ;(useResearchStore as jest.Mock).mockReturnValue({ + ...mockResearchStore, + activeResearchItem: FactoryResearchItem({ + subscribers: [activeUser.userName], + }), + activeUser, + }) + + // Act + const wrapper = getWrapper() + const followingButton = wrapper.getByTestId('following-button') + + // Assert + expect(wrapper.getAllByText('Following').length).toBeGreaterThan(0) + + expect(followingButton).toBeInTheDocument() + expect(followingButton).toHaveAttribute( + 'iconcolor', + Theme.colors.subscribed, + ) + }) + describe('Research Update', () => { it('displays contributors', async () => { // Arrange @@ -147,7 +195,11 @@ describe('Research Article', () => { const getWrapper = () => { return render( - + { )}