scratch-www/test/unit/components/email-confirmation-banner.test.jsx

36 lines
1.3 KiB
React
Raw Permalink Normal View History

2021-11-02 10:53:16 -04:00
const React = require('react');
const {mountWithIntl} = require('../../helpers/intl-helpers.jsx');
const EmailConfirmationBanner = require('../../../src/components/dropdown-banner/email-confirmation/banner.jsx');
2021-12-02 16:23:17 -05:00
jest.mock('../../../src/components/modal/email-confirmation/modal.jsx', () => () => 'MockEmailConfirmationModal');
2021-11-02 10:53:16 -04:00
describe('EmailConfirmationBanner', () => {
test('Clicking "Confirm your email" opens the email confirmation modal', () => {
const component = mountWithIntl(
<EmailConfirmationBanner />
);
2021-12-02 16:23:17 -05:00
expect(component.text()).not.toContain('MockEmailConfirmationModal');
const confirmWrapper = component.find({id: 'emailConfirmationBanner.confirm'});
2023-01-06 15:55:16 -05:00
const confirmLink = mountWithIntl(confirmWrapper.props().values.confirmLink);
confirmLink.simulate('click');
component.update();
2021-12-02 16:23:17 -05:00
expect(component.text()).toContain('MockEmailConfirmationModal');
2021-11-02 10:53:16 -04:00
});
test('Clicking X calls onRequestDismiss', () => {
const requestDismissMock = jest.fn();
const component = mountWithIntl(
<EmailConfirmationBanner onRequestDismiss={requestDismissMock} />
);
component.find('a.close').simulate('click', {preventDefault () {}});
expect(requestDismissMock).toHaveBeenCalled();
});
});