subscriptionBox.spec.jsx 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*global global*/
  2. import React from 'react';
  3. import {mount} from 'enzyme';
  4. import SubscriptionBox from 'app/views/settings/organizationDeveloperSettings/subscriptionBox';
  5. describe('SubscriptionBox', () => {
  6. let wrapper;
  7. let onChange;
  8. beforeEach(() => {
  9. onChange = jest.fn();
  10. wrapper = mount(
  11. <SubscriptionBox
  12. resource={'issue'}
  13. checked={false}
  14. disabled={false}
  15. onChange={onChange}
  16. />,
  17. TestStubs.routerContext()
  18. );
  19. });
  20. it('renders resource checkbox', () => {
  21. expect(wrapper).toMatchSnapshot();
  22. });
  23. it('updates state and calls onChange prop when checking checkbox', () => {
  24. wrapper.find('Checkbox input').simulate('change', {target: {checked: true}});
  25. expect(wrapper.state('checked')).toBe(true);
  26. expect(onChange).toHaveBeenCalledWith('issue', true);
  27. });
  28. it('renders tooltip when checkbox is disabled', () => {
  29. wrapper.setProps({disabled: true});
  30. expect(wrapper.find('Tooltip').prop('disabled')).toBe(false);
  31. });
  32. });