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

70 lines
1.9 KiB
TypeScript
Raw Normal View History

2022-05-17 10:10:40 -07:00
import { Map as ImmutableMap } from 'immutable';
import React from 'react';
import { render, screen } from '../../jest/test-helpers';
import { normalizeAccount } from '../../normalizers';
import Account from '../account';
2022-07-06 11:12:35 -07:00
import type { ReducerAccount } from 'soapbox/reducers/accounts';
2022-05-17 10:10:40 -07:00
describe('<Account />', () => {
it('renders account name and username', () => {
const account = normalizeAccount({
id: '1',
acct: 'justin-username',
display_name: 'Justin L',
avatar: 'test.jpg',
2022-07-06 11:12:35 -07:00
}) as ReducerAccount;
2022-05-17 10:10:40 -07:00
const store = {
accounts: ImmutableMap({
'1': account,
}),
};
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', () => {
const account = normalizeAccount({
id: '1',
acct: 'justin-username',
display_name: 'Justin L',
avatar: 'test.jpg',
verified: true,
2022-07-06 11:12:35 -07:00
}) as ReducerAccount;
2022-05-17 10:10:40 -07:00
const store = {
accounts: ImmutableMap({
'1': account,
}),
};
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', () => {
const account = normalizeAccount({
id: '1',
acct: 'justin-username',
display_name: 'Justin L',
avatar: 'test.jpg',
verified: false,
2022-07-06 11:12:35 -07:00
}) as ReducerAccount;
2022-05-17 10:10:40 -07:00
const store = {
accounts: ImmutableMap({
'1': account,
}),
};
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);
});
});
});