2016-11-16 16:58:25 +00:00
|
|
|
import React from 'react';
|
|
|
|
|
import expect, { createSpy, restoreSpies } from 'expect';
|
|
|
|
|
import { mount } from 'enzyme';
|
|
|
|
|
import { noop } from 'lodash';
|
|
|
|
|
|
|
|
|
|
import ConfirmationPage from 'components/forms/RegistrationForm/ConfirmationPage';
|
|
|
|
|
|
|
|
|
|
describe('ConfirmationPage - form', () => {
|
|
|
|
|
afterEach(restoreSpies);
|
|
|
|
|
|
|
|
|
|
const formData = {
|
|
|
|
|
username: 'jmeller',
|
|
|
|
|
email: 'jason@kolide.co',
|
|
|
|
|
org_name: 'Kolide',
|
2016-11-21 20:22:14 +00:00
|
|
|
kolide_server_url: 'http://kolide.kolide.co',
|
2016-11-16 16:58:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
it('renders the user information', () => {
|
|
|
|
|
const form = mount(
|
|
|
|
|
<ConfirmationPage
|
|
|
|
|
formData={formData}
|
|
|
|
|
handleSubmit={noop}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
expect(form.text()).toInclude(formData.username);
|
|
|
|
|
expect(form.text()).toInclude(formData.email);
|
|
|
|
|
expect(form.text()).toInclude(formData.org_name);
|
2016-11-21 20:22:14 +00:00
|
|
|
expect(form.text()).toInclude(formData.kolide_server_url);
|
2016-11-16 16:58:25 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('submits the form', () => {
|
|
|
|
|
const handleSubmitSpy = createSpy();
|
|
|
|
|
const form = mount(
|
|
|
|
|
<ConfirmationPage
|
|
|
|
|
formData={formData}
|
|
|
|
|
handleSubmit={handleSubmitSpy}
|
|
|
|
|
/>
|
|
|
|
|
);
|
2017-01-11 19:27:33 +00:00
|
|
|
const htmlForm = form.find('form');
|
2016-11-16 16:58:25 +00:00
|
|
|
|
2017-01-11 19:27:33 +00:00
|
|
|
htmlForm.simulate('submit');
|
2016-11-16 16:58:25 +00:00
|
|
|
|
|
|
|
|
expect(handleSubmitSpy).toHaveBeenCalled();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|