ScrollTopButton: fix tests, actually don't use shortNumberFormat for now (it messes up pluralization)

dnd
Alex Gleason 2022-06-03 13:16:22 -05:00
rodzic fbb460817f
commit d0130fb296
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
2 zmienionych plików z 9 dodań i 17 usunięć

Wyświetl plik

@ -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();
});
});

Wyświetl plik

@ -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>