import {mountWithTheme, shallow} from 'sentry-test/enzyme'; import {initializeOrg} from 'sentry-test/initializeOrg'; import EventOrGroupHeader from 'app/components/eventOrGroupHeader'; const data = { metadata: { type: 'metadata type', directive: 'metadata directive', uri: 'metadata uri', value: 'metadata value', message: 'metadata message', }, culprit: 'culprit', }; describe('EventOrGroupHeader', function () { const {routerContext} = initializeOrg(); describe('Group', function () { const groupData = { ...data, level: 'error', id: 'id', }; it('renders with `type = error`', function () { const component = mountWithTheme( , routerContext ); expect(component).toSnapshot(); }); it('renders with `type = csp`', function () { const component = mountWithTheme( , routerContext ); expect(component).toSnapshot(); }); it('renders with `type = default`', function () { const component = mountWithTheme( , routerContext ); expect(component).toSnapshot(); }); it('renders metadata values in message for error events', function () { const component = mountWithTheme( , routerContext ); const message = component.find('Message'); expect(message.text()).toEqual('metadata value'); }); it('renders location', function () { const component = mountWithTheme( , routerContext ); const location = component.find('Location'); expect(location.text()).toEqual('in path/to/file.swift'); }); }); describe('Event', function () { const eventData = { ...data, id: 'id', eventID: 'eventID', groupID: 'groupID', culprit: undefined, }; it('renders with `type = error`', function () { const component = mountWithTheme( , routerContext ); expect(component).toSnapshot(); }); it('renders with `type = csp`', function () { const component = mountWithTheme( , routerContext ); expect(component).toSnapshot(); }); it('renders with `type = default`', function () { const component = mountWithTheme( , routerContext ); expect(component).toSnapshot(); }); it('hides level tag', function () { const component = mountWithTheme( , routerContext ); expect(component).toSnapshot(); }); it('keeps sort in link when query has sort', function () { const query = { sort: 'freq', }; const component = shallow( ); const title = component.dive().dive().instance().getTitle(); expect(title.props.to.query.sort).toEqual('freq'); }); it('lack of project adds allp parameter', function () { const query = {}; const component = shallow( ); const title = component.dive().dive().instance().getTitle(); expect(title.props.to.query._allp).toEqual(1); }); }); });