2022-04-28 17:10:54 -04:00
|
|
|
import React from 'react';
|
|
|
|
import {mountWithIntl} from '../../helpers/intl-helpers.jsx';
|
|
|
|
import DonateTopBanner from '../../../src/views/splash/donate/donate-banner';
|
|
|
|
|
|
|
|
describe('DonateBannerTest', () => {
|
|
|
|
let realDateNow;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
realDateNow = Date.now.bind(global.Date);
|
|
|
|
});
|
|
|
|
afterEach(() => {
|
|
|
|
global.Date.now = realDateNow;
|
|
|
|
});
|
2022-04-28 17:25:53 -04:00
|
|
|
test('Testing Scratch week banner message', () => {
|
2022-05-23 12:38:18 -04:00
|
|
|
global.Date.now = () => new Date(2022, 3, 16).getTime();
|
2022-04-28 17:10:54 -04:00
|
|
|
const component = mountWithIntl(
|
|
|
|
<DonateTopBanner />
|
|
|
|
);
|
2022-04-28 17:25:53 -04:00
|
|
|
|
2022-04-28 17:10:54 -04:00
|
|
|
expect(component.find('div.donate-banner').exists()).toEqual(true);
|
|
|
|
expect(component.find('p.donate-text').exists()).toEqual(true);
|
2022-04-28 17:25:53 -04:00
|
|
|
expect(component.find('FormattedMessage[id="donatebanner.scratchWeek"]').exists()).toEqual(true);
|
|
|
|
expect(component.find('FormattedMessage[id="donatebanner.askSupport"]').exists()).toEqual(false);
|
|
|
|
|
2022-04-28 17:10:54 -04:00
|
|
|
});
|
2023-10-24 14:22:28 -04:00
|
|
|
test('testing default message comes back after May 21', () => {
|
2022-04-28 17:25:53 -04:00
|
|
|
// Date after Scratch week
|
|
|
|
global.Date.now = () => new Date(2022, 4, 22).getTime();
|
2022-04-28 17:10:54 -04:00
|
|
|
const component = mountWithIntl(
|
|
|
|
<DonateTopBanner />
|
|
|
|
);
|
|
|
|
expect(component.find('div.donate-banner').exists()).toEqual(true);
|
|
|
|
expect(component.find('p.donate-text').exists()).toEqual(true);
|
2022-04-28 17:25:53 -04:00
|
|
|
expect(component.find('FormattedMessage[id="donatebanner.askSupport"]').exists()).toEqual(true);
|
|
|
|
expect(component.find('FormattedMessage[id="donatebanner.scratchWeek"]').exists()).toEqual(false);
|
2022-04-28 17:10:54 -04:00
|
|
|
});
|
|
|
|
});
|