Hide carousel if no avatars

This commit is contained in:
Justin 2022-07-11 09:10:10 -04:00
parent 1254f8a3f3
commit 96e47962c9
2 changed files with 24 additions and 0 deletions

View file

@ -56,11 +56,31 @@ describe('<FeedCarousel />', () => {
});
it('should render the Carousel', () => {
store.carousels = {
avatars: [
{ account_id: '1', acct: 'a', account_avatar: 'https://example.com/some.jpg' },
],
};
render(<FeedCarousel />, undefined, store);
expect(screen.queryAllByTestId('feed-carousel')).toHaveLength(1);
});
describe('with 0 avatars', () => {
beforeEach(() => {
store.carousels = {
avatars: [],
};
});
it('renders the error message', () => {
render(<FeedCarousel />, undefined, store);
expect(screen.queryAllByTestId('feed-carousel-error')).toHaveLength(0);
});
});
describe('with a failed request to the API', () => {
beforeEach(() => {
store.carousels = {

View file

@ -93,6 +93,10 @@ const FeedCarousel = () => {
);
}
if (avatars.length === 0) {
return null;
}
return (
<Card variant='rounded' size='lg' ref={cardRef} className='relative' data-testid='feed-carousel'>
<div>