soapbox/src/components/account.test.tsx

68 wiersze
1.6 KiB
TypeScript
Czysty Zwykły widok Historia

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