-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SDPA-2451] Adds additional status messages for grants. (#464)
* [SDPA-2451] Adds additional status messages for grants. * Handles closing today case * update test
- Loading branch information
1 parent
dba6c26
commit 79d039c
Showing
7 changed files
with
417 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
142 changes: 142 additions & 0 deletions
142
packages/components/Organisms/Grants/__tests__/grantsoverview.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
import { mount } from '@vue/test-utils' | ||
import { RplGrantsOverview } from './../index' | ||
const MockDate = require('mockdate') | ||
|
||
describe('RplGrantsOverview', () => { | ||
const defaultProps = { | ||
title: '', | ||
funding: { | ||
from: '', | ||
to: '' | ||
}, | ||
audience: '', | ||
startdate: '', | ||
enddate: '', | ||
description: '', | ||
link: { | ||
url: '', | ||
text: '' | ||
}, | ||
listing: false | ||
} | ||
afterEach(() => { | ||
MockDate.reset() | ||
}) | ||
|
||
it('displays status as "closed" when current date is after start date and after end date', () => { | ||
MockDate.set('2019-04-13T06:19:17+00:00') | ||
|
||
const wrapper = mount(RplGrantsOverview, { | ||
propsData: { | ||
...defaultProps, | ||
startdate: '2019-04-10T06:19:17+00:00', | ||
enddate: '2019-04-12T06:19:17+00:00' | ||
} | ||
}) | ||
expect(wrapper.find('[data-tid="grants-status"]').text()).toEqual('Closed') | ||
}) | ||
|
||
it('displays status as "closed" when current date is after end date and there is no start date', () => { | ||
MockDate.set('2019-04-13T06:19:17+00:00') | ||
|
||
const wrapper = mount(RplGrantsOverview, { | ||
propsData: { | ||
...defaultProps, | ||
startdate: '', | ||
enddate: '2019-04-12T06:19:17+00:00' | ||
} | ||
}) | ||
expect(wrapper.find('[data-tid="grants-status"]').text()).toEqual('Closed') | ||
}) | ||
|
||
it('displays status as "Opening on startdate" when current date is within one month of startdate', () => { | ||
MockDate.set('2019-03-11T06:19:17+00:00') | ||
|
||
const wrapper = mount(RplGrantsOverview, { | ||
propsData: { | ||
...defaultProps, | ||
startdate: '2019-04-10T06:19:17+00:00', | ||
enddate: '2019-05-10T06:19:17+00:00' | ||
} | ||
}) | ||
expect(wrapper.find('[data-tid="grants-status"]').text()).toEqual('Opening on 10 April') | ||
}) | ||
|
||
it('displays status as "Closed" when current date is more than one month of startdate', () => { | ||
MockDate.set('2019-01-10T06:19:17+00:00') | ||
|
||
const wrapper = mount(RplGrantsOverview, { | ||
propsData: { | ||
...defaultProps, | ||
startdate: '2019-02-10T06:19:17+00:00', | ||
enddate: '2019-05-10T06:19:17+00:00' | ||
} | ||
}) | ||
expect(wrapper.find('[data-tid="grants-status"]').text()).toEqual('Closed') | ||
}) | ||
|
||
it('displays status as "Open, closing in x days" when current date is more start date and less than end date', () => { | ||
MockDate.set('2019-04-11T06:19:17+00:00') | ||
|
||
const wrapper = mount(RplGrantsOverview, { | ||
propsData: { | ||
...defaultProps, | ||
startdate: '2019-04-09T06:19:17+00:00', | ||
enddate: '2019-05-10T06:19:17+00:00' | ||
} | ||
}) | ||
expect(wrapper.find('[data-tid="grants-status"]').text()).toEqual('Open, closing in 29 days') | ||
}) | ||
|
||
it('displays status as "Open, closing in 1 day" when current date is after start date and 1 day from end date', () => { | ||
MockDate.set('2019-04-11T06:19:17+00:00') | ||
|
||
const wrapper = mount(RplGrantsOverview, { | ||
propsData: { | ||
...defaultProps, | ||
startdate: '2019-04-10T06:19:17+00:00', | ||
enddate: '2019-04-12T06:19:17+00:00' | ||
} | ||
}) | ||
expect(wrapper.find('[data-tid="grants-status"]').text()).toEqual('Open, closing in 1 day') | ||
}) | ||
|
||
it('displays status as "Open, closes today" when current date is after start date and the same as end date', () => { | ||
MockDate.set('2019-04-12T06:19:17+00:00') | ||
|
||
const wrapper = mount(RplGrantsOverview, { | ||
propsData: { | ||
...defaultProps, | ||
startdate: '2019-04-10T06:19:17+00:00', | ||
enddate: '2019-04-12T07:19:17+00:00' | ||
} | ||
}) | ||
expect(wrapper.find('[data-tid="grants-status"]').text()).toEqual('Open, closing today') | ||
}) | ||
|
||
it('displays status as "Ongoing" if there is no end date and the current date is after the start date', () => { | ||
MockDate.set('2019-04-12T06:19:17+00:00') | ||
|
||
const wrapper = mount(RplGrantsOverview, { | ||
propsData: { | ||
...defaultProps, | ||
startdate: '2019-04-11T06:19:17+00:00', | ||
enddate: '' | ||
} | ||
}) | ||
expect(wrapper.find('[data-tid="grants-status"]').text()).toEqual('Ongoing') | ||
}) | ||
|
||
it('displays status as "Ongoing" if there is no start or end date', () => { | ||
MockDate.set('2019-04-12T06:19:17+00:00') | ||
|
||
const wrapper = mount(RplGrantsOverview, { | ||
propsData: { | ||
...defaultProps, | ||
startdate: '', | ||
enddate: '' | ||
} | ||
}) | ||
expect(wrapper.find('[data-tid="grants-status"]').text()).toEqual('Ongoing') | ||
}) | ||
}) |
Oops, something went wrong.