Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Commit

Permalink
feat(project): handle campaign due dates in overview
Browse files Browse the repository at this point in the history
  • Loading branch information
demmyhonore committed Nov 2, 2020
1 parent fb97c81 commit 0faebf5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ export default function ActiveCampaignOverviewItem ({ scoreImage, scoreTitle, ca
{campaignTitle}
</Typography>
<Typography>
{campaignDeadline ? `${campaignDeadline} ${t('days_to_go')}` : null}
{campaignDeadline
? (campaignDeadline > 0 ? `${campaignDeadline} ${t('days_to_go')}` : t('past_due_date'))
: null}
</Typography>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,22 @@ describe('<ActiveCampaignOverviewItem />', () => {
expect(container.firstChild).toMatchSnapshot();
});

it('it renders the score title, campaign title and campaign deadline correctly', () => {
it('renders the score title, campaign title and campaign deadline correctly', () => {
const { getByText } = render(<ActiveCampaignOverviewItem {...dummyProps} />);

expect(getByText('bb')).toBeTruthy();
expect(getByText('cc')).toBeTruthy();
});

it('renders the campaign deadline if its a positive integer', () => {
const { getByText } = render(<ActiveCampaignOverviewItem campaignDeadline={10} {...dummyProps} />);

expect(getByText(/days to go/i)).toBeTruthy();
});

it('renders past due date if campaign deadline if below zero', () => {
const { getByText } = render(<ActiveCampaignOverviewItem campaignDeadline={-10} {...dummyProps} />);

expect(getByText(/due date/i)).toBeTruthy();
});
});
1 change: 1 addition & 0 deletions src/i18n/locales/en/campaign.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"help_us_digitize": "Help us digitize",
"help_us_digitize_untitled": "Help us digitize this untitled project",
"more": "More",
"past_due_date": "Past due date",
"download": "Download",
"share_this_campaign": "Share this campaign",
"start_your_own_campaign": "Start your own campaign",
Expand Down

0 comments on commit 0faebf5

Please sign in to comment.