UNPKG

@eureca/eureca-ui

Version:

UI component library of Eureca's user and admin apps

52 lines (43 loc) 1.46 kB
import React from 'react'; import { render } from '@testing-library/react'; import { OpportunityTimer } from '../opportunity-timer'; const mockData = { title: 'Título', date: new Date(), image: 'image', progress: 33, }; function renderOpportunityTimerCard({ title, date, image, progress }) { return render( <OpportunityTimer title={title} date={date} image={image} progress={progress} data-testid="main-testid" /> ); } describe('Opportunity Timer card component', () => { it('renders', () => { const { getByTestId } = renderOpportunityTimerCard(mockData); const card = getByTestId('main-testid'); expect(card).not.toBeNull(); }); it('has a title rendered', () => { const { getByText } = renderOpportunityTimerCard(mockData); const title = getByText(mockData.title); expect(title).toBeInstanceOf(HTMLElement); expect(title.textContent).toBe(mockData.title); }); it('has a translated body text rendered', () => { const { getByText } = renderOpportunityTimerCard(mockData); const bodyText = getByText('Encerra hoje'); expect(bodyText.textContent).toBe('Encerra hoje'); }); it('uses the image prop to display using background url', () => { const { getByTestId } = renderOpportunityTimerCard(mockData); const coverElement = getByTestId('cover-image-testid'); expect(coverElement.style.background).toBe('url(image) no-repeat'); }); });