Hide carousel if no avatars
This commit is contained in:
parent
1254f8a3f3
commit
96e47962c9
2 changed files with 24 additions and 0 deletions
|
@ -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 = {
|
||||||
|
|
|
@ -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>
|
||||||
|
|
Loading…
Reference in a new issue