Make it start now and stop after may 21

This commit is contained in:
picklesrus 2022-04-28 17:25:53 -04:00
parent 29bbd5c720
commit 0566724640
2 changed files with 15 additions and 18 deletions

View file

@ -14,8 +14,6 @@ const navigateToDonatePage = () => {
window.location = donateURL;
};
// For Scratch week
const SCRATCH_CELBRATION_BANNER_START_TIME = new Date(2022, 4, 16).getTime(); // May 16 2022 (months are zero indexed)
const SCRATCH_CELBRATION_BANNER_END_TIME = new Date(2022, 4, 21).getTime(); // May 21 2022 (months are zero indexed)
// Following the example in the Google Analytics doc here to track
@ -41,8 +39,7 @@ const DonateTopBanner = ({
src="/images/ideas/try-it-icon.svg"
/>
<div className="donate-central-items">
{(Date.now() >= SCRATCH_CELBRATION_BANNER_START_TIME &&
Date.now() < SCRATCH_CELBRATION_BANNER_END_TIME) ?
{(Date.now() < SCRATCH_CELBRATION_BANNER_END_TIME) ?
(
<p className="donate-text">
<FormattedMessage

View file

@ -11,9 +11,20 @@ describe('DonateBannerTest', () => {
afterEach(() => {
global.Date.now = realDateNow;
});
test('Testing regular banner message', () => {
// Date outside of scratch week
global.Date.now = () => new Date(2021, 4, 19).getTime();
test('Testing Scratch week banner message', () => {
const component = mountWithIntl(
<DonateTopBanner />
);
expect(component.find('div.donate-banner').exists()).toEqual(true);
expect(component.find('p.donate-text').exists()).toEqual(true);
expect(component.find('FormattedMessage[id="donatebanner.scratchWeek"]').exists()).toEqual(true);
expect(component.find('FormattedMessage[id="donatebanner.askSupport"]').exists()).toEqual(false);
});
test('testing default message comes back after May 21 ', () => {
// Date after Scratch week
global.Date.now = () => new Date(2022, 4, 22).getTime();
const component = mountWithIntl(
<DonateTopBanner />
);
@ -22,15 +33,4 @@ describe('DonateBannerTest', () => {
expect(component.find('FormattedMessage[id="donatebanner.askSupport"]').exists()).toEqual(true);
expect(component.find('FormattedMessage[id="donatebanner.scratchWeek"]').exists()).toEqual(false);
});
test('testing time sensitive scratch week banner message ', () => {
// Date within Scratch week 2022
global.Date.now = () => new Date(2022, 4, 19).getTime();
const component = mountWithIntl(
<DonateTopBanner />
);
expect(component.find('div.donate-banner').exists()).toEqual(true);
expect(component.find('p.donate-text').exists()).toEqual(true);
expect(component.find('FormattedMessage[id="donatebanner.scratchWeek"]').exists()).toEqual(true);
expect(component.find('FormattedMessage[id="donatebanner.askSupport"]').exists()).toEqual(false);
});
});