Merge branch 'fix-empty-carousel' into 'develop'

Hide carousel if no avatars

Closes #1029

See merge request soapbox-pub/soapbox-fe!1624
This commit is contained in:
Justin 2022-07-11 15:05:46 +00:00
commit 818db57f8e
2 changed files with 24 additions and 0 deletions

View file

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

View file

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