bigbuffet-rw/app/soapbox/components/__tests__/scroll-top-button.test.tsx
marcin mikołajczak 7b5114a1b8 prefer TypeScript for tests
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2022-06-12 23:07:06 +02:00

43 lines
1.2 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', { hidden: true })).toBeInTheDocument();
render(
<ScrollTopButton
key='scroll-top-button'
onClick={() => {}}
count={9999999}
message={messages.queue}
/>,
);
expect(screen.getByText('Click to see 9999999 new posts', { hidden: true })).toBeInTheDocument();
});
});