pleroma/app/soapbox/components/__tests__/status.test.tsx

45 lines
1.3 KiB
TypeScript
Raw Normal View History

2022-11-09 11:23:33 -08:00
import React from 'react';
2023-06-26 10:41:42 -07:00
import { buildAccount } from 'soapbox/jest/factory';
import { render, screen, rootState } from 'soapbox/jest/test-helpers';
import { normalizeStatus } from 'soapbox/normalizers';
2022-11-09 11:23:33 -08:00
import Status from '../status';
import type { ReducerStatus } from 'soapbox/reducers/statuses';
2023-06-26 10:41:42 -07:00
const account = buildAccount({
2022-11-09 11:23:33 -08:00
id: '1',
acct: 'alex',
});
const status = normalizeStatus({
id: '1',
account,
content: 'hello world',
contentHtml: 'hello world',
}) as ReducerStatus;
describe('<Status />', () => {
const state = rootState.setIn(['accounts', '1'], account);
it('renders content', () => {
render(<Status status={status} />, undefined, state);
screen.getByText(/hello world/i);
expect(screen.getByTestId('status')).toHaveTextContent(/hello world/i);
});
describe('the Status Action Bar', () => {
it('is rendered', () => {
render(<Status status={status} />, undefined, state);
expect(screen.getByTestId('status-action-bar')).toBeInTheDocument();
});
it('is not rendered if status is under review', () => {
2023-06-26 10:41:42 -07:00
const inReviewStatus = status.set('visibility', 'self');
2022-11-09 11:23:33 -08:00
render(<Status status={inReviewStatus as ReducerStatus} />, undefined, state);
expect(screen.queryAllByTestId('status-action-bar')).toHaveLength(0);
});
});
});