bigbuffet-rw/app/soapbox/components/__tests__/scroll-top-button.test.tsx
2022-07-06 13:12:35 -05:00

43 lines
1.1 KiB
TypeScript

import React from 'react';
import { defineMessages } from 'react-intl';
import { render, screen } from '../../jest/test-helpers';
import ScrollTopButton from '../scroll-top-button';
const messages = defineMessages({
queue: { id: 'status_list.queue_label', defaultMessage: 'Click to see {count} new {count, plural, one {post} other {posts}}' },
});
describe('<ScrollTopButton />', () => {
it('renders correctly', async() => {
render(
<ScrollTopButton
key='scroll-top-button'
onClick={() => {}}
count={0}
message={messages.queue}
/>,
);
expect(screen.queryAllByRole('link')).toHaveLength(0);
render(
<ScrollTopButton
key='scroll-top-button'
onClick={() => {}}
count={1}
message={messages.queue}
/>,
);
expect(screen.getByText('Click to see 1 new post')).toBeInTheDocument();
render(
<ScrollTopButton
key='scroll-top-button'
onClick={() => {}}
count={9999999}
message={messages.queue}
/>,
);
expect(screen.getByText('Click to see 9999999 new posts')).toBeInTheDocument();
});
});