Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@doodle/components / structure / Navigation / CreatePollMenu / CreatePollMenu.spec.js
Size: Mime:
import React from 'react';
import { mount } from 'enzyme';
import CreatePollMenu from './CreatePollMenu';
import userData from '../fixture';

describe('CreatePollMenu', () => {
  it('should match the snapshot', () => {
    const component = mount(<CreatePollMenu />);
    expect(component.getElement()).toMatchSnapshot();
  });

  it('should only render a create button (no dropdown menu) if the user is not logged in', () => {
    const component = mount(<CreatePollMenu />);
    expect(component.find({ href: '/create' }));
  });

  it('should call the function passed into onClickCreatePoll', () => {
    const mockFunction = jest.fn();
    const component = mount(<CreatePollMenu onClickCreatePoll={mockFunction} user={userData} />);
    const button = component.find('.Menu span.Button');
    button.simulate('click');
    const menuItem = component.find(`span.Menu-item[data-testid='navigation-menu-create-date-poll']`);
    menuItem.simulate('click');
    expect(mockFunction).toHaveBeenCalled();
  });

  it('should call the function passed into onClickCreateOneOnOne', () => {
    const mockFunction = jest.fn();
    const component = mount(<CreatePollMenu onClickCreateOneOnOne={mockFunction} user={userData} />);
    const button = component.find('.Menu span.Button');
    button.simulate('click');
    const menuItem = component.find(`span.Menu-item[data-testid='navigation-menu-create-d11']`);
    menuItem.simulate('click');
    expect(mockFunction).toHaveBeenCalled();
  });

  it('should call the function passed into onClickCreateSurvey', () => {
    const mockFunction = jest.fn();
    const component = mount(<CreatePollMenu onClickCreateSurvey={mockFunction} user={userData} />);
    const button = component.find('.Menu span.Button');
    button.simulate('click');
    const menuItem = component.find(`span.Menu-item[data-testid='navigation-menu-create-text-poll']`);
    menuItem.simulate('click');
    expect(mockFunction).toHaveBeenCalled();
  });
});