2022-06-02 18:46:18 -07:00
|
|
|
import { fromJS } from 'immutable';
|
2020-06-09 19:29:50 -07:00
|
|
|
import React from 'react';
|
|
|
|
import { defineMessages } from 'react-intl';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2022-04-04 08:53:47 -07:00
|
|
|
import { render, screen } from '../../jest/test-helpers';
|
2022-06-03 10:34:30 -07:00
|
|
|
import ScrollTopButton from '../scroll-top-button';
|
2020-06-09 19:29:50 -07:00
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
queue: { id: 'status_list.queue_label', defaultMessage: 'Click to see {count} new {count, plural, one {post} other {posts}}' },
|
|
|
|
});
|
|
|
|
|
2022-06-03 10:34:30 -07:00
|
|
|
describe('<ScrollTopButton />', () => {
|
2022-04-04 08:53:47 -07:00
|
|
|
it('renders correctly', async() => {
|
|
|
|
render(
|
2022-06-03 10:34:30 -07:00
|
|
|
<ScrollTopButton
|
|
|
|
key='scroll-top-button'
|
2020-06-09 19:29:50 -07:00
|
|
|
onClick={() => {}} // eslint-disable-line react/jsx-no-bind
|
2022-06-02 18:46:18 -07:00
|
|
|
timelineId='home'
|
2020-06-09 19:29:50 -07:00
|
|
|
message={messages.queue}
|
2020-10-07 11:08:36 -07:00
|
|
|
/>,
|
2022-06-02 18:46:18 -07:00
|
|
|
undefined,
|
|
|
|
{ timelines: fromJS({ home: { totalQueuedItemsCount: 0 } }) },
|
2022-04-04 08:53:47 -07:00
|
|
|
);
|
|
|
|
expect(screen.queryAllByRole('link')).toHaveLength(0);
|
2020-06-09 19:29:50 -07:00
|
|
|
|
2022-04-04 08:53:47 -07:00
|
|
|
render(
|
2022-06-03 10:34:30 -07:00
|
|
|
<ScrollTopButton
|
|
|
|
key='scroll-top-button'
|
2020-06-09 19:29:50 -07:00
|
|
|
onClick={() => {}} // eslint-disable-line react/jsx-no-bind
|
2022-06-02 18:46:18 -07:00
|
|
|
timelineId='home'
|
2020-06-09 19:29:50 -07:00
|
|
|
message={messages.queue}
|
2020-10-07 11:08:36 -07:00
|
|
|
/>,
|
2022-06-02 18:46:18 -07:00
|
|
|
undefined,
|
|
|
|
{ timelines: fromJS({ home: { totalQueuedItemsCount: 1 } }) },
|
2022-04-04 08:53:47 -07:00
|
|
|
);
|
2022-06-02 18:59:34 -07:00
|
|
|
expect(screen.getByText(/Click to see\s+1\s+new post/, { hidden: true })).toBeInTheDocument();
|
2020-06-09 19:29:50 -07:00
|
|
|
|
2022-04-04 08:53:47 -07:00
|
|
|
render(
|
2022-06-03 10:34:30 -07:00
|
|
|
<ScrollTopButton
|
|
|
|
key='scroll-top-button'
|
2020-06-09 19:29:50 -07:00
|
|
|
onClick={() => {}} // eslint-disable-line react/jsx-no-bind
|
2022-06-02 18:46:18 -07:00
|
|
|
timelineId='home'
|
2020-06-09 19:29:50 -07:00
|
|
|
message={messages.queue}
|
2020-10-07 11:08:36 -07:00
|
|
|
/>,
|
2022-06-02 18:46:18 -07:00
|
|
|
undefined,
|
|
|
|
{ timelines: fromJS({ home: { totalQueuedItemsCount: 9999999 } }) },
|
2022-04-04 08:53:47 -07:00
|
|
|
);
|
2022-06-02 18:59:34 -07:00
|
|
|
expect(screen.getByText(/10.*M/, { hidden: true })).toBeInTheDocument();
|
2020-06-09 19:29:50 -07:00
|
|
|
});
|
|
|
|
});
|