bigbuffet-rw/app/soapbox/components/__tests__/account.test.tsx

68 lines
1.6 KiB
TypeScript
Raw Normal View History

2022-05-17 10:10:40 -07:00
import React from 'react';
2023-06-20 12:24:39 -07:00
import { buildAccount } from 'soapbox/jest/factory';
2022-05-17 10:10:40 -07:00
import { render, screen } from '../../jest/test-helpers';
import Account from '../account';
describe('<Account />', () => {
it('renders account name and username', () => {
2023-06-20 12:24:39 -07:00
const account = buildAccount({
2022-05-17 10:10:40 -07:00
id: '1',
acct: 'justin-username',
display_name: 'Justin L',
avatar: 'test.jpg',
2023-06-20 12:24:39 -07:00
});
2022-05-17 10:10:40 -07:00
const store = {
2023-06-20 15:48:57 -07:00
accounts: {
2022-05-17 10:10:40 -07:00
'1': account,
2023-06-20 15:48:57 -07:00
},
2022-05-17 10:10:40 -07:00
};
2022-07-06 11:12:35 -07:00
render(<Account account={account} />, undefined, store);
2022-05-17 10:10:40 -07:00
expect(screen.getByTestId('account')).toHaveTextContent('Justin L');
expect(screen.getByTestId('account')).toHaveTextContent(/justin-username/i);
});
describe('verification badge', () => {
it('renders verification badge', () => {
2023-06-20 12:24:39 -07:00
const account = buildAccount({
2022-05-17 10:10:40 -07:00
id: '1',
acct: 'justin-username',
display_name: 'Justin L',
avatar: 'test.jpg',
verified: true,
2023-06-20 12:24:39 -07:00
});
2022-05-17 10:10:40 -07:00
const store = {
2023-06-20 15:48:57 -07:00
accounts: {
2022-05-17 10:10:40 -07:00
'1': account,
2023-06-20 15:48:57 -07:00
},
2022-05-17 10:10:40 -07:00
};
2022-07-06 11:12:35 -07:00
render(<Account account={account} />, undefined, store);
2022-05-17 10:10:40 -07:00
expect(screen.getByTestId('verified-badge')).toBeInTheDocument();
});
it('does not render verification badge', () => {
2023-06-20 12:24:39 -07:00
const account = buildAccount({
2022-05-17 10:10:40 -07:00
id: '1',
acct: 'justin-username',
display_name: 'Justin L',
avatar: 'test.jpg',
verified: false,
2023-06-20 12:24:39 -07:00
});
2022-05-17 10:10:40 -07:00
const store = {
2023-06-20 15:48:57 -07:00
accounts: {
2022-05-17 10:10:40 -07:00
'1': account,
2023-06-20 15:48:57 -07:00
},
2022-05-17 10:10:40 -07:00
};
2022-07-06 11:12:35 -07:00
render(<Account account={account} />, undefined, store);
2022-05-17 10:10:40 -07:00
expect(screen.queryAllByTestId('verified-badge')).toHaveLength(0);
});
});
});