import React from 'react';
import { mount } from 'enzyme';
import OrganizationAdd from '../../../../src/pages/Organizations/views/Organization.add';
describe('', () => {
test('initially renders succesfully', () => {
mount(
);
});
test('calls "handleChange" when input values change', () => {
const spy = jest.spyOn(OrganizationAdd.prototype, 'handleChange');
const wrapper = mount(
);
expect(spy).not.toHaveBeenCalled();
wrapper.find('input#add-org-form-name').simulate('change', {target: {value: 'foo'}});
wrapper.find('input#add-org-form-description').simulate('change', {target: {value: 'bar'}});
expect(spy).toHaveBeenCalledTimes(2);
});
test('calls "onSubmit" when Save button is clicked', () => {
const spy = jest.spyOn(OrganizationAdd.prototype, 'onSubmit');
const wrapper = mount(
);
expect(spy).not.toHaveBeenCalled();
wrapper.find('button.at-C-SubmitButton').prop('onClick')();
expect(spy).toBeCalled();
});
});