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

56 lines
1.8 KiB
React
Raw Normal View History

2021-12-01 16:30:22 -05:00
const React = require('react');
const {mountWithIntl} = require('../../helpers/intl-helpers.jsx');
const EmailConfirmationModal = require('../../../src/components/modal/email-confirmation/modal.jsx');
import configureStore from 'redux-mock-store';
describe('Modal', () => {
const mockStore = configureStore();
let defaultStore;
const testEmail = 'test123@email.com';
beforeEach(() => {
defaultStore = mockStore({
session: {
session: {
user: {
email: testEmail
},
permissions: {}
}
}
});
});
test('Display email prop correctly', () => {
const component = mountWithIntl(
<EmailConfirmationModal
isOpen
/>, {context: {store: defaultStore}}
);
2021-12-17 15:32:30 -05:00
expect(component.find('div.modal-text-content').text()).toContain(testEmail);
2021-12-01 16:30:22 -05:00
});
2021-12-02 14:56:38 -05:00
test('Clicking on Text changes to tips page', () => {
const component = mountWithIntl(
<EmailConfirmationModal
isOpen
/>, {email: testEmail, context: {store: defaultStore}}
);
2021-12-03 08:42:12 -05:00
const tipsLinkWrapper = component.find({id: 'emailConfirmationModal.havingTrouble'});
2023-01-06 15:55:16 -05:00
const tipsLink = mountWithIntl(tipsLinkWrapper.props().values.tipsLink);
2021-12-02 14:56:38 -05:00
tipsLink.simulate('click');
2021-12-03 08:42:12 -05:00
expect(component.text()).toContain('emailConfirmationModal.confirmingTips');
2021-12-02 14:56:38 -05:00
});
2021-12-01 16:30:22 -05:00
test('Close button shows correctly', () => {
const component = mountWithIntl(
2021-12-16 16:10:40 -05:00
<EmailConfirmationModal isOpen />, {context: {store: defaultStore}}
2021-12-01 16:30:22 -05:00
);
2021-12-16 16:10:40 -05:00
expect(component.find('div.modal-content-close').exists()).toBe(true);
expect(component.find('img.modal-content-close-img').exists()).toBe(true);
2021-12-01 16:30:22 -05:00
});
});