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'
|
2022-06-03 11:16:22 -07:00
|
|
|
onClick={() => {}}
|
|
|
|
count={0}
|
2020-06-09 19:29:50 -07:00
|
|
|
message={messages.queue}
|
2020-10-07 11:08:36 -07:00
|
|
|
/>,
|
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'
|
2022-06-03 11:16:22 -07:00
|
|
|
onClick={() => {}}
|
|
|
|
count={1}
|
2020-06-09 19:29:50 -07:00
|
|
|
message={messages.queue}
|
2020-10-07 11:08:36 -07:00
|
|
|
/>,
|
2022-04-04 08:53:47 -07:00
|
|
|
);
|
2022-06-03 11:16:22 -07:00
|
|
|
expect(screen.getByText('Click to see 1 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'
|
2022-06-03 11:16:22 -07:00
|
|
|
onClick={() => {}}
|
|
|
|
count={9999999}
|
2020-06-09 19:29:50 -07:00
|
|
|
message={messages.queue}
|
2020-10-07 11:08:36 -07:00
|
|
|
/>,
|
2022-04-04 08:53:47 -07:00
|
|
|
);
|
2022-06-03 11:16:22 -07:00
|
|
|
expect(screen.getByText('Click to see 9999999 new posts', { hidden: true })).toBeInTheDocument();
|
2020-06-09 19:29:50 -07:00
|
|
|
});
|
|
|
|
});
|