import React from 'react';
import { mount } from 'enzyme';

import nativeDispatch from './nativeDispatch';

describe('dev server entry', () => {
  it('Be able to render the application', () => {
    const cb = jest.fn();
    // eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events
    const node = mount(<div onClick={e => nativeDispatch(e, cb, 'hi world')}></div>);
    node.simulate('click');
    expect(cb).toHaveBeenCalled();
  });

  it('should still render with alternate event payloads', () => {
    const event = {
      target: {
        dispatchEvent: jest.fn(),
      },
      rest: {
        value: 'test',
      },
    };
    nativeDispatch(event);
    expect(event.target.dispatchEvent).toHaveBeenCalled();
  });
});
