diff --git a/app/components/TrackCard/tests/index.test.js b/app/components/TrackCard/tests/index.test.js index aadcd66..fcf0842 100644 --- a/app/components/TrackCard/tests/index.test.js +++ b/app/components/TrackCard/tests/index.test.js @@ -11,38 +11,40 @@ import { translate } from '@app/utils/index'; describe('', () => { it('should render and match the snapshot', () => { - const { baseElement } = renderWithIntl(); + const mockSetTrackPlaying = jest.fn(); + const { baseElement } = renderWithIntl(); expect(baseElement).toMatchSnapshot(); }); it('should contain 1 TrackCard component', () => { - const { getAllByTestId } = renderWithIntl(); + const mockSetTrackPlaying = jest.fn(); + const { getAllByTestId } = renderWithIntl(); expect(getAllByTestId('track-card').length).toBe(1); }); it('should render the track details inside the card', () => { - const collectionName = 'Sunflower'; - const artistName = 'Post Malone'; - const shortDescription = ''; - const artworkUrl100 = 'https://someurl.com'; - const previewUrl = ''; - const { getByTestId } = renderWithIntl( - - ); - expect(getByTestId('collectionName')).toHaveTextContent(collectionName); + const mockSetTrackPlaying = jest.fn(); + const trackData = { + collectionName: 'Sunflower', + artistName: 'Post Malone', + shortDescription: 'Sample Description', + artworkUrl100: 'https://example.com/image.jpg', + previewUrl: 'https://example.com/preview.mp3' + }; + const { getByTestId } = renderWithIntl(); + + expect(getByTestId('collectionName')).toHaveTextContent(trackData.collectionName); + expect(getByTestId('artistName')).toHaveTextContent(trackData.artistName); + expect(getByTestId('track_shortdesc')).toHaveTextContent(trackData.shortDescription); }); it('should render the track unavailable messages in case any props are unavailable or have falsy values', () => { + const mockSetTrackPlaying = jest.fn(); const collectionNameUnavailable = translate('collection_name_unavailable'); const artistNameUnavailable = translate('track_artist_name_unavailable'); const shortDescriptionUnavailable = translate('track_shortdesc_unavailable'); - const { getByTestId } = renderWithIntl(); + + const { getByTestId } = renderWithIntl(); expect(getByTestId('collection_name_unavailable')).toHaveTextContent(collectionNameUnavailable); expect(getByTestId('track_artist_name_unavailable')).toHaveTextContent(artistNameUnavailable); expect(getByTestId('track_shortdesc_unavailable')).toHaveTextContent(shortDescriptionUnavailable);