Repository URL to install this package:
|
Version:
5.6.5 ▾
|
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();
});
it('should call the function passed into onClickCreateBookableCalendar', () => {
const mockFunction = jest.fn();
const component = mount(<CreatePollMenu onClickCreateBookableCalendar={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-bookable-calendar']`);
menuItem.simulate('click');
expect(mockFunction).toHaveBeenCalled();
});
});