123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- import React from 'react';
- import PropTypes from 'prop-types';
- import {shallow} from 'enzyme';
- import {browserHistory} from 'react-router';
- import OrgnanizationGroupEvents from 'app/views/groupDetails/organization/groupEvents';
- describe('groupEvents', function() {
- beforeEach(function() {
- MockApiClient.addMockResponse({
- url: '/issues/1/events/',
- body: TestStubs.Events(),
- });
- browserHistory.push = jest.fn();
- });
- it('renders', function() {
- const component = shallow(
- <OrgnanizationGroupEvents
- group={TestStubs.Group()}
- params={{orgId: 'orgId', projectId: 'projectId', groupId: '1'}}
- location={{query: {}}}
- />,
- {
- context: {...TestStubs.router()},
- childContextTypes: {
- router: PropTypes.object,
- },
- }
- );
- expect(component).toMatchSnapshot();
- });
- it('handles search', function() {
- const component = shallow(
- <OrgnanizationGroupEvents
- params={{orgId: 'orgId', projectId: 'projectId', groupId: '1'}}
- group={TestStubs.Group()}
- location={{query: {}}}
- />,
- {
- context: {...TestStubs.router()},
- childContextTypes: {
- router: PropTypes.object,
- },
- }
- );
- const list = [
- {searchTerm: '', expectedQuery: ''},
- {searchTerm: 'test', expectedQuery: 'test'},
- {searchTerm: 'environment:production test', expectedQuery: 'test'},
- ];
- list.forEach(item => {
- component.instance().handleSearch(item.searchTerm);
- expect(browserHistory.push).toHaveBeenCalledWith(
- expect.objectContaining({
- query: {query: item.expectedQuery},
- })
- );
- });
- });
- });
|