sforkowany z mirror/soapbox
ScrollTopButton: fix tests, actually don't use shortNumberFormat for now (it messes up pluralization)
rodzic
fbb460817f
commit
d0130fb296
|
@ -1,4 +1,3 @@
|
|||
import { fromJS } from 'immutable';
|
||||
import React from 'react';
|
||||
import { defineMessages } from 'react-intl';
|
||||
|
||||
|
@ -14,37 +13,31 @@ describe('<ScrollTopButton />', () => {
|
|||
render(
|
||||
<ScrollTopButton
|
||||
key='scroll-top-button'
|
||||
onClick={() => {}} // eslint-disable-line react/jsx-no-bind
|
||||
timelineId='home'
|
||||
onClick={() => {}}
|
||||
count={0}
|
||||
message={messages.queue}
|
||||
/>,
|
||||
undefined,
|
||||
{ timelines: fromJS({ home: { totalQueuedItemsCount: 0 } }) },
|
||||
);
|
||||
expect(screen.queryAllByRole('link')).toHaveLength(0);
|
||||
|
||||
render(
|
||||
<ScrollTopButton
|
||||
key='scroll-top-button'
|
||||
onClick={() => {}} // eslint-disable-line react/jsx-no-bind
|
||||
timelineId='home'
|
||||
onClick={() => {}}
|
||||
count={1}
|
||||
message={messages.queue}
|
||||
/>,
|
||||
undefined,
|
||||
{ timelines: fromJS({ home: { totalQueuedItemsCount: 1 } }) },
|
||||
);
|
||||
expect(screen.getByText(/Click to see\s+1\s+new post/, { hidden: true })).toBeInTheDocument();
|
||||
expect(screen.getByText('Click to see 1 new post', { hidden: true })).toBeInTheDocument();
|
||||
|
||||
render(
|
||||
<ScrollTopButton
|
||||
key='scroll-top-button'
|
||||
onClick={() => {}} // eslint-disable-line react/jsx-no-bind
|
||||
timelineId='home'
|
||||
onClick={() => {}}
|
||||
count={9999999}
|
||||
message={messages.queue}
|
||||
/>,
|
||||
undefined,
|
||||
{ timelines: fromJS({ home: { totalQueuedItemsCount: 9999999 } }) },
|
||||
);
|
||||
expect(screen.getByText(/10.*M/, { hidden: true })).toBeInTheDocument();
|
||||
expect(screen.getByText('Click to see 9999999 new posts', { hidden: true })).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -6,7 +6,6 @@ import { useIntl, MessageDescriptor } from 'react-intl';
|
|||
import Icon from 'soapbox/components/icon';
|
||||
import { Text } from 'soapbox/components/ui';
|
||||
import { useSettings } from 'soapbox/hooks';
|
||||
import { shortNumberFormat } from 'soapbox/utils/numbers';
|
||||
|
||||
interface IScrollTopButton {
|
||||
/** Callback when clicked, and also when scrolled to the top. */
|
||||
|
@ -79,7 +78,7 @@ const ScrollTopButton: React.FC<IScrollTopButton> = ({
|
|||
|
||||
{(count > 0) && (
|
||||
<Text theme='inherit' size='sm'>
|
||||
{intl.formatMessage(message, { count: shortNumberFormat(count) })}
|
||||
{intl.formatMessage(message, { count })}
|
||||
</Text>
|
||||
)}
|
||||
</a>
|
||||
|
|
Ładowanie…
Reference in New Issue